in reply to requesting small regex
Hi! any chance someone could give me a small regex to split any non-alphanomeric characters from a string?
You should be able to write it yourself after reading http://perldoc.perl.org/perlintro.html#Regular-expressions subsection http://perldoc.perl.org/perlintro.html#More-complex-regular-expressions it should take about 10 seconds
$ perl -MRegexp::English -le " print Regexp::English->new->non_word_char "
(?^:\W)
$ perl -MYAPE::Regex::Explain -le " print YAPE::Regex::Explain->new( q/\W/ )->explain "
The regular expression:
(?-imsx:\W)
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
\W non-word characters (all but a-z, A-Z, 0-
9, _)
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: requesting small regex
by Anonymous Monk on May 07, 2012 at 07:19 UTC |