Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1362

preg_replace help

Date 2011-05-02 07:45 -0400
From bill <nobody@spamcop.net>
Newsgroups comp.lang.php
Subject preg_replace help
Message-ID <oNidnfTM6dv7BCPQnZ2dnUVZ_gydnZ2d@cablespeedmi.com> (permalink)

Show all headers | View raw


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

Back to comp.lang.php | Previous | NextNext in thread | Find similar


Thread

preg_replace help bill <nobody@spamcop.net> - 2011-05-02 07:45 -0400
  Re: preg_replace help Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-02 08:19 -0400
    Re: preg_replace help bill <nobody@spamcop.net> - 2011-05-02 11:44 -0400
      Re: preg_replace help "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-05-02 18:51 +0200
        Re: preg_replace help bill <nobody@spamcop.net> - 2011-05-04 06:41 -0400
    Re: preg_replace help Michael Fesser <netizen@gmx.de> - 2011-05-02 18:05 +0200
  Re: preg_replace help "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-05-02 16:19 +0200

csiph-web