Posted by Edward Z. Yang on 05/24/07 22:48
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ben wrote:
> I want to do the following:
>
> replace __abc__ with <b>abc</b> in a string
Don't use grep. Try this (untested):
preg_replace('/__([a-z0-9]+)__/i', '<b>$1</b>', $string);
You may want to expand the character class.
- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.org> Anti-XSS HTML Filter
[[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGVhZWqTO+fYacSNoRAoRwAJ9sFagIahwNchBKqgY8RgPn7qb+fQCfbouO
Yfq3Z6Mii++oowl1GL8ItyE=
=LqGd
-----END PGP SIGNATURE-----
Navigation:
[Reply to this message]
|