On Wed, 24 Dec 2003 00:28:02 +0100, "The Plankmeister"
<pl******************@hotmail.com> wrote:
I'm sure this should work:
echo preg_replace("/(\w)(\!w)(\w)/","\\1\. \\3","this is.a test.to see. if
it. works");
It should output:
this is. a test. to see. if it. works
But it doesn't. The string is unaltered. What am I doing wrong?
What is \!w ? Did you want \W (non-word character)?
Did you really want to replace with \. instead of .? (. is not special in the
_replacement_).
$1 is the preferred syntax over \1 for matches (particularly within regexes
when used as backreferences because of the ambiguities with character codes).
Perhaps:
echo preg_replace("/(\w)(\W)(\w)/",
"$1. $3",
"this is.a test.to see. if it. works");
--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (
http://www.andyh.co.uk)
Space: disk usage analysis tool (
http://www.andyhsoftware.co.uk/space)