[pmwiki-users] Regex help (excluding spaces)

Eric Forgeot eforgeot at gmail.com
Sat Mar 9 13:58:39 CST 2013


Hello,

I'm trying to improve a cookbook 
(http://www.pmwiki.org/wiki/Cookbook/Txt2tags) and I have difficulties 
with regex.

I want for example a special markup with **bold** to be marked as bold.

I have this line:

     Markup ('txt2tags_bold'     , 'directives', '/\*\*(.*?)\*\*/'       
, "'''$1'''");

It works but I get wrong output when having for example **this and 
**this, because this kind of text is not supposed to be marked as bold.  
(**this and** should be bold on the other hand)

So I modified my rule this way, to exclude white spaces before or after:

     Markup ('txt2tags_bold'     , 'directives', 
'/\*\*[^\s](.*?)[^\s]\*\*/'       , "'''$1'''");

Now it almost works, **this and **this are not catched, but the bold 
parts are not correct, the first and last letters are striped out, for 
example **another** would become nothe (in bold). Do you know why, and 
how to correct this?





More information about the pmwiki-users mailing list