vcherubini
Programmer
Hello:
I am having a bit of trouble with a regular expression I am writing for PHP.
I am using the preg_replace() function so that I can use a nice Perl regular expression.
I want to search through a string that containts PHP variables that begin with a $ so I have constructed the following regular expression:
[tt]
$html = "<html><head><title>$title</title></head><body>$user <br>$pass <br> this string has vars in it </body></html>";
$pattern = "/(\$\D+.?\D)/";
$replace = "/ /gi/";
preg_replace($pattern,$replace,$html);
[/tt]
I want to search through HTML and replace everything that begine with $ and has some characters after it, to be replaced with a space.
In Perl, I constructed the following regular expression and it works fine:
[tt]
$html = "<html><head><title>$title</title></head><body>$user <br>$pass <br> this string has vars in it </body></html>";
$html =~ s/\$\b+.?\b/ /gi;
[/tt]
What is wrong with my PHP code?
Any help is appreciated.
Thank,
-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
I am having a bit of trouble with a regular expression I am writing for PHP.
I am using the preg_replace() function so that I can use a nice Perl regular expression.
I want to search through a string that containts PHP variables that begin with a $ so I have constructed the following regular expression:
[tt]
$html = "<html><head><title>$title</title></head><body>$user <br>$pass <br> this string has vars in it </body></html>";
$pattern = "/(\$\D+.?\D)/";
$replace = "/ /gi/";
preg_replace($pattern,$replace,$html);
[/tt]
I want to search through HTML and replace everything that begine with $ and has some characters after it, to be replaced with a space.
In Perl, I constructed the following regular expression and it works fine:
[tt]
$html = "<html><head><title>$title</title></head><body>$user <br>$pass <br> this string has vars in it </body></html>";
$html =~ s/\$\b+.?\b/ /gi;
[/tt]
What is wrong with my PHP code?
Any help is appreciated.
Thank,
-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====