On Tue, 23 Mar 2004 00:27:02 GMT, "Stijn Goris" <me*****@hotmail.com> wrote:
Hi all,
I m trying to create a smiley system but no luck
I have
preg_replace ("/:-)/", '<img src="images/smiley.gif">', $strings);
but it returns Warning: Compilation failed: unmatched parentheses at offset
2
I have looked in the manual but no luck so far
Parentheses are ( and ).
These are used to capture patterns.
For each ( there must be a ).
If you want to match a literal ( or a literal ) you must escape them.
To escape characters you use \.
You're not including any variables in the pattern, so use single quotes. This
also means you can stop worrying about any confusion with PHP's escaping
mechanism.
preg_replace ('/:-\)/', '<img src="images/smiley.gif">', $strings);
Since there's nothing variable in your pattern match anyway, regular
expressions are overkill, so just use str_replace.
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk /
http://www.andyhsoftware.co.uk/space