Posted by Jake on 02/23/06 22:43
I am trying to write a regular expression that will strip out wikicode
links. The links can be in the following two formats.
[[xxx]] or [[yyy|xxx]]
I want to display "xxx" in all cases. This is the closest that I have
come up with
$text = ereg_replace ("\[\[([^|\]]*\|)?([^\]]*)\]\]", "\\2",$text);
Which breaks down to this
\[\[ first brackets
([^|\]]*\|)? optional characters ending with |
([^\]]*) all characters up to ]
\]\] last brackets
Unfortunatly, it only matches single character x's or y's. In other
words it only matches "[[x]] [[y|x]]" and I dont know why because I
have the * in there to match any number of characters. Any ideas would
be very helpful.
[Back to original message]
|