Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Strip non-numeric

by krujos (Curate)
on Jan 13, 2003 at 22:50 UTC ( #226636=note: print w/ replies, xml ) Need Help??


in reply to Strip non-numeric

Try this  $var =~ s/\D//g; This (untested) code will remove all non-numeric characters from the string.

Josh
Update: I fixed my type where I left the g off the regexp. Sorry
Update:2 I also fixed the /// problem that tall_man pointed out. Thanks.


Comment on Re: Strip non-numeric
Download Code
Re: Re: Strip non-numeric
by tall_man (Parson) on Jan 13, 2003 at 22:54 UTC
    There's one extra "/" at the end, and no "g" flag so only one would be removed. You need:
    $var =~ s/\D//g;
    Update: The "g" was just fixed in the message I replied to, but not the extra "/"
    Update 2:Now all the problems are fixed. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://226636]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-04 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls