Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression... Can't figure it out...

Status
Not open for further replies.

handle87

Programmer
Jun 27, 2005
53
CA
Hi...
I just can't figure out how to use regular expressions and preg_replace...
Code:
$pattern = "[A-Z][a-z]+";
$replacement = "XXX";
$string = "Test";
echo preg_replace($patterns, $replacements, $string);

I need to above to echo "XXX" can someone please tell e the silly thing I am going wrong??

C
 
Finnally figured it outI guess it is monday..

Code:
$patterns = "[a-zA-Z]";
$replacements = "XXX";
$string = "Test";
echo ereg_replace($patterns, $replacements, $string);

Output is "XXXXXXXXXXXX";

 
or:
ereg_replace("/[a-z]/gi", $replacements, $string);

i - case insensitive
g - global...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top