Hybride Posted December 15, 2010 Share Posted December 15, 2010 Hi everyone, Am trying to create a regular expression that finds the word before the parenthesis in user's query. This is what I mean: type(object). needthis(user'sQuery). Or in a highly complex situation, needthis(word1, word2) :- needalso(x, y), needalso(y,z). Any ideas on how to do this? Help greatly appreciated. (For those of you curious, am trying to find the predicates in a prolog statement.) Quote Link to comment Share on other sites More sharing options...
mikecampbell Posted December 16, 2010 Share Posted December 16, 2010 $str = "needthis(word1, word2) :- needalso(x, y), needalso(y,z)."; preg_match_all('/([a-z]+)\s*\(/i', $str, $matches); print_r($matches[1]); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.