Code: Select all
preg_match_all ('/!.*?.!/',$val5,$out2);
Moderator: General Moderators
Code: Select all
preg_match_all ('/!.*?.!/',$val5,$out2);
Code: Select all
/(!.*!)/Actually, in your regex the '!' is not the delimiter, the matching '/' chars are the delimiters. The only error with your regex is the extra dot right before the second '!' which matches any char in this position (which you don't want). Remove the second dot and your regex works just fine.LDusan wrote:Since '/' or '#' or other special characters are used to delimit regular expression, how could I write expression in which the expression itself starts and end with special characters. For example:
This won't work, I guess because '!' is taken as delimiter instead of '/'. Any ideas?Code: Select all
preg_match_all ('/!.*?.!/',$val5,$out2);
Code: Select all
$count = preg_match_all ('/![^!]*!/', $subject, $matches);