music_lp90 Posted October 30, 2008 Share Posted October 30, 2008 Hi, I need a regular expression that finds a pattern like this {mosInclude}ANYTHING IN BETWEEN{/mosInclude}. So I want it to find the {mosInclude} opening and closing tags with anything between them. Thanks for any help! Link to comment Share on other sites More sharing options...
jesh Posted October 30, 2008 Share Posted October 30, 2008 Something along these lines? /{mosInclude}(.+?){/mosInclude}/ Link to comment Share on other sites More sharing options...
music_lp90 Posted October 30, 2008 Author Share Posted October 30, 2008 Thanks Jesh, I think it is finding the trigger, but I'm getting an error: Warning: preg_replace() [function.preg-replace]: Unknown modifier 'o' in C:\wamp\www\mambots\content\mosInclude.php on line 22This is line 22: $row->text = preg_replace( $find, $replace, $row->text );I'm not sure what Unkown modifier 'o' means. Link to comment Share on other sites More sharing options...
Ingolme Posted October 30, 2008 Share Posted October 30, 2008 I think the expression needs some escaping. And I think a * would be better than +?/\{mosInclude\}(.*)\{\/mosInclude\}/ Link to comment Share on other sites More sharing options...
jesh Posted October 30, 2008 Share Posted October 30, 2008 And I think a * would be better than +? If there is a chance of there being two sets of {mosInclude}{/mosInclude}s in the string to match, then the lazy lookup (?) would be more appropriate. You're probably right, however, that .*? (lazy zero-or-more) would be better than .+? (lazy one-or-more). Link to comment Share on other sites More sharing options...
music_lp90 Posted October 31, 2008 Author Share Posted October 31, 2008 Thanks Ingolme, it works great now! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.