0

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

1
  • Thanks for wanting to mark the question as solved. To do that, just tick your answer by clicking the tick mark on the left. It should go green. Thanks! Commented Aug 19, 2014 at 18:15

1 Answer 1

1

Fixed!

I changed the regular expression to /\{\{([a-zA-Z]+)\|([a-zA-Z]+)\|([a-zA-Z ]+)\}\}/ and now it works :D

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.