Home »
Imported messages »
comp.lang.php »
Regular Expressions
Regular Expressions [message #174032] |
Fri, 20 May 2011 00:03  |
bruceaj
Messages: 30 Registered: September 2010
Karma: 0
|
Member |
|
|
I have the need for a regular expression. I haven't written one for
more then 20 years, and even then I wasn't good!!
I have a string, $parmStr, that contains a mixture of characters and
digits (0-9). I want to extract all none digits and return a string
with ONLY the digits.
Greatly appreciate it someone could show me what I am looking for.
Thank you very much
Bruce
|
|
|
|
|
|
Re: Regular Expressions [message #174045 is a reply to message #174032] |
Fri, 20 May 2011 07:47  |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
El 20/05/2011 2:03, bruceaj escribió/wrote:
> I have the need for a regular expression. I haven't written one for
> more then 20 years, and even then I wasn't good!!
>
> I have a string, $parmStr, that contains a mixture of characters and
> digits (0-9). I want to extract all none digits and return a string
> with ONLY the digits.
>
> Greatly appreciate it someone could show me what I am looking for.
Untested:
preg_replace('/[^\d]+/', '', $parmStr);
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|
Goto Forum:
Current Time: Sun Mar 09 14:27:43 GMT 2025
Total time taken to generate the page: 0.07333 seconds