Page 1 of 1

Simple Markup regex

Posted: Tue Nov 15, 2005 9:15 pm
by Nathaniel
So I have 3 patterns:

Code: Select all

array('/^\*([^*]+)\*$/ms', 
'/^\_([^_]+)\_$/ms', 
'/^\%([^\%]+)\%$/ms');
3 replacements:

Code: Select all

array('<strong>$1</strong>', 
'<em>$1</em>', 
'<small>$1</small>');
That gaggle of nonsense is suposed to replace *some text which needs to be bolded* with <strong>some text that needs to be bolded</strong>, etc - without running across multiple lines.

*this is valid bold markup*

*this
isn't

valid*

Instead, it doesn't replace anything. What do I need to change?

Edit: I now realize the m modifier in there isn't what I want... I need some form of "not * and not line break" regex...

- Nathaniel

Posted: Tue Nov 15, 2005 9:40 pm
by Nathaniel
Wow!

Code: Select all

'#\*([^*\n]+)\*#m'
is all it took!

I did try \n in there before... but I think it still didn't work because of my s modifier at the end...