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.) Link to comment https://forums.phpfreaks.com/topic/221720-find-word-before-parenthesis/ 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]); Link to comment https://forums.phpfreaks.com/topic/221720-find-word-before-parenthesis/#findComment-1148054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.