Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: regex to remove all non a-z and spaces

by mrborisguy (Hermit)
on May 16, 2005 at 02:53 UTC ( #457342=note: print w/replies, xml ) Need Help??


in reply to Re^2: regex to remove all non a-z and spaces
in thread regex to remove all non a-z and spaces

usually, ^ does mean at the beginning, but the [ and ] make a character class, and a ^ at the beginning of a character class means "not any of these".

Update:
Oddly enough, it doesn't explicitly say that in perlre. however, it does say
You can negate the [::] character classes by prefixing the class name with a '^'. This is a Perl extension.
  • Comment on Re^3: regex to remove all non a-z and spaces

Replies are listed 'Best First'.
Re^4: regex to remove all non a-z and spaces
by coldfingertips (Pilgrim) on May 16, 2005 at 02:57 UTC
    So what it's really saying is "s/// anything that is not within our class"? So s/[^0-9\.-]//g; would be an example on how to remove any non number (except - and .)?
      yep! you got it.
        Ahhh, dang! I never knew you could do something like this, this is awesome. Thanks!!
Re^4: regex to remove all non a-z and spaces
by hv (Parson) on May 16, 2005 at 11:02 UTC

    Oops, that's a strange omission in the docs (though negating character classes is briefly mentioned in perlrequick and perlretut.

    Just for the record, it is specifically the negation of POSIX character classes that is a perl extension - /[^a-z]/ is straight from Henry Spencer's original code.

    Hugo

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2020-02-25 21:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (113 votes). Check out past polls.

    Notices?