You are here: Regular Expression help « PHP Programming Language « IT news, forums, messages
Regular Expression help

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация