I need pregmatch to ring true if my reg expression is: aloe vera and the string contains any combination of aloe vera: aloe vera, aloevera, aloe vera gel , aloe veragel i thought i could do this with the regex modifiers /ix but x is not working for me
try these tools http://www.fileformat.info/tool/regex.htm http://www.gskinner.com/RegExr/ Regards Alex
yeah i tried that here are my results so far here is my string aloe vera aloe vera aloevera aloe vera juice if i use /aloe vera/gism match: aloe vera aloe vera aloevera aloe vera juice if I use /aloe vera/gixsm aloe vera aloe vera aloevera aloe vera juice i want one general expression that will capture all the aloe vera's with our without whitespace i mean think in the extreme, if somehow someone wrote alo e ver a i want to match it
Why has this gone unnecessarily complex? $word = 'some aloeveragel and some aloe vera gel and some aloevera'; preg_match_all('/aloe ?vera ?(gel)?/', $word, $matches); print_r($matches); PHP: Does the job fine... returns: Array ( [0] => aloeveragel [1] => aloe vera gel [2] => aloevera ) Code (markup):
so basically you are just searching for aloe somewhere in the string? how is would this reply if you wanted to do: credit card AND creditcard but not credit by itself
<?php $word = 'This will find credit card and creditcard but not credit - how awesome!'; preg_match_all('/credit ?card/', $word, $matches); print_r($matches); ?> PHP: Returns: Array ( [0] => Array ( [0] => credit card [1] => creditcard ) ) Code (markup):
ok see that is what i don't get ? means optional so that reads to me credit and optional card so how does it know not to match just credit
No... 'credit' optional space, and 'card'. The ? operator only refers to the item directly before it... In this case - the space.
sorry i have a site that if you are an affiliate referral of mine, i convert those words to your affiliate id however there are plenty of tutorial on the net for converting links, i just coun't get the words to match like iw anted