in reply to stripping everything but numbers and letters

Tested it.
It works, but what I meant to ask, is if there is a down fall to doing it that way, or if there is a better way to do it?

  • Comment on Re: stripping everything but numbers and letters

Replies are listed 'Best First'.
Re^2: stripping everything but numbers and letters
by jettero (Monsignor) on Feb 06, 2009 at 11:33 UTC
    I might use this, $string =~ s/[^\w\d.-]+//g, but it's nearly the same thing. I think it's just fine.

    -Paul

Re^2: stripping everything but numbers and letters
by AnomalousMonk (Archbishop) on Feb 06, 2009 at 18:37 UTC
    I don't understand: When you said 'number' in your OP, did you mean 'decimal digit', i.e., '0' through '9' (as represented by the character set [0-9] or \d), or did you mean something like 'signed integer' or 'rational number', e.g., '-21' or '+4.2'?

    I notice that you and some other posters include '+', '.' and '-' in their character sets, which suggests a 'rational number' interpretation. If this is the case, you definitely need a different approach.