[pmwiki-devel] regex question

Hans design5 at softflow.co.uk
Thu Jan 24 09:23:47 CST 2008


Thursday, January 24, 2008, 2:16:43 PM, Dominique wrote:

> 1. get the substring enclosed into [@ ... @] markup
> 2. into this substring, replace all occurences of "matched" by "@]matched[@".
> 3. rebuild the resulting string.

Thank you! I managed this now with a preg_match_all
and processing any matching sections individually:

if(preg_match_all("/(\\[@[^\\]]+)($pat)(.*?@\\])/".$qi."", $row, $mb)) {
   foreach($mb[0] as $i => $v) {
     $mbnew = preg_replace("/($pat)/".$qi."", "@]'''$1'''[@", $mb[0][$i]);
     $row = str_replace( $mb[0][$i], $mbnew, $row);
   }
}
else
  $row = preg_replace("/($pat)/".$qi."","'''$1'''", $row);


Hans




More information about the pmwiki-devel mailing list