Reputation: 31
I have a text and I want to do something like Wiki code, creating links with [[]] and stuffs.
I am using this preg_replace to do that, and it seems to work:
<?=preg_replace("/\{\{([^\*]+)\|([^\*]+)\|([^\*]+)\}\}/", "<a href='$1.php#$2'>$3</a>", $conditions['pattern']); ?>
The problem is that when I have this text "can[not] build at %{{types|location|location}}% %{{some|other|stuff}}%" it outputs this:
can[not] build at %<a href="types|location|location}}% %{{some.php#other">stuff</a>%
It's like only the last one gets replaced, but wrong.
Any idea? Thanks
Upvotes: 0
Views: 516
Reputation: 31
Fixed!
I changed the regular expression to /\{\{([a-zA-Z]+)\|([a-zA-Z]+)\|([a-zA-Z ]+)\}\}/
and now it works :D
Upvotes: 1