bsmither Posted November 11, 2014 Share Posted November 11, 2014 I found this regex, which is what I want, here: (?=.*\bdog\b)(?=.*\bpuppet\b)(?=.*\bfuzzy\b) It is suppose to 'succeed' if it can find all the given words in any order. Yet, when I try to test it against this sequence of words (or any other order of these words): need fuzzy hand puppet in dogpen for dog I get no indication of a match. What am I not understanding? Quote Link to comment https://forums.phpfreaks.com/topic/292399-multiple-words-any-order/ Share on other sites More sharing options...
requinix Posted November 11, 2014 Share Posted November 11, 2014 (edited) I think regexpal can't handle it. Edited November 11, 2014 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/292399-multiple-words-any-order/#findComment-1496292 Share on other sites More sharing options...
bsmither Posted November 11, 2014 Author Share Posted November 11, 2014 Interesting. Other than using your browser's javascript console, do you (or anyone here) have a console app that succeeds in showing a true result? Such as: http://forums.phpfreaks.com/topic/282231-at-last-regexbuddy-4-released/ Personally, I tried with The Regex Coach (v0.9.2, copyright 2008, Dr. Edmund Weitz) and Rad Software Regular Expression Designer (v1.4, copyright 2007, Ross Donald). May be I don't know how to use the Rad Software app. Quote Link to comment https://forums.phpfreaks.com/topic/292399-multiple-words-any-order/#findComment-1496297 Share on other sites More sharing options...
requinix Posted November 11, 2014 Share Posted November 11, 2014 Command-line? $ php -r "var_dump(preg_match('/(?=.*\bdog\b)(?=.*\bpuppet\b)(?=.*\bfuzzy\b)/', 'need fuzzy hand puppet in dogpen for dog'));" int(1)It works. Quote Link to comment https://forums.phpfreaks.com/topic/292399-multiple-words-any-order/#findComment-1496300 Share on other sites More sharing options...
bsmither Posted November 11, 2014 Author Share Posted November 11, 2014 Thank you for your assistance with this. It has proved to be enlightening, To close this out, the expression I needed is to be used in a MySQL query. From the actual source code I was trying to modify, I knew the word boundary indicator is different. But there is more. I have also come to learn MySQL uses the POSIX language for it's RE engine, which means there is no lookahead. However, regardless of whether it is efficient or not, I will probably have to use: (`abc` RLIKE expr1) AND (`abc` RLIKE expr2) AND ... Quote Link to comment https://forums.phpfreaks.com/topic/292399-multiple-words-any-order/#findComment-1496337 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.