Reply to Re: Regular Expression help

Your name:

Reply:


Posted by Ian Taylor on 02/23/06 23:24

Jake wrote:
> 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);

This seems to work for me (using preg_replace instead of ereg_replace,
which uses the Perl regex engine, and is faster IIRC):

echo preg_replace("/\[\[.*?\|?([^\|\]]*)?\]\]/" ,"\\1", $text1);

HTH,

Ian.

[Back to original 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

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