in reply to Regex help
If you want anything that isn't a digit or a leter (or an underscore), then you might consider using: \W
while ($in =~ /\W/) { # do something }
Or:
while ($in !~ /\w/) { ... }
Otherwise:
while ($in =~ /[^a-zA-Z0-9]/) { # do something }
Or:
while ($in !~ /[a-zA-Z0-9]/) { ... }
There's not much to chose between =~ and !~, but I generally like the emphasis of saying "as long as it's not one of these things..."
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Regex help
by fruiture (Curate) on Nov 17, 2002 at 12:00 UTC |
In Section
Seekers of Perl Wisdom