|
Posted by gosha bine on 05/25/07 08:13
On 25.05.2007 00:26 Ben wrote:
> I want to do the following:
>
> replace __abc__ with <b>abc</b> in a string
>
> Any help?
>
> Ben
>
preg_replace('/__(\w+?)__/', '<b>$1</b>', $string)
or
preg_replace('/\b__(\w+?)__\b/', '<b>$1</b>', $string)
the latter replaces only whole words, i.e. "xxx __blah__ xxx" but not
"zzz__blah___zzz".
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Navigation:
[Reply to this message]
|