FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » preg_replace help
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
preg_replace help [message #173734] Mon, 02 May 2011 11:45 Go to previous message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma:
Senior Member
unfortunately the documentation, while telling one how to use
preg_replace, does not tell how to write a regular expression.

In this case google is not my friend as the tutorial I read
suggested (as _I_ read it):

$contact = preg_replace("[0-9\-]*","",$contact);

when I want to return a string that contains only numbers or the
hyphen (a telephone number in the US).

preg_replace does not like the * which the tutorial says means
"do it over and over"

and $contact = preg_replace("[0-9\-]","",$contact);
doesn not modify the string at all.

a bit of help (or a lot of help) would be appreciated (no, I have
not been in school for quite some time, Jerry)

bill
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to extract value using php soapclient
Next Topic: Upgraded -- But Still Showing Old PHP Version
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 02:28:59 GMT 2024

Total time taken to generate the page: 0.05057 seconds