Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Looking for a regular expression for the following pattern.

by Anonymous Monk
on Mar 30, 2018 at 02:22 UTC ( #1212013=note: print w/replies, xml ) Need Help??


in reply to Re^2: Looking for a regular expression for the following pattern.
in thread Looking for a regular expression for the following pattern.

The first two requirements sound like the same thing: /([:alnum:]+[_]+/. But the third requirement is a subset of the first, consuming the alnum sequence with no need for underscore. Two regexes joined by || logical-or would do it. However, it just might be as simple as replacing the last + in the above regex with * to indicate "zero or more" underscores. The pattern now looks for one-or-more alnum characters followed by zero-or-more underscores.
  • Comment on Re^3: Looking for a regular expression for the following pattern.

Replies are listed 'Best First'.
Re^4: Looking for a regular expression for the following pattern.
by AnomalousMonk (Archbishop) on Mar 30, 2018 at 15:03 UTC

    So  'a_________'  '%%a_____%%'  '123456789_' would be strings skooma would want to match? That wasn't my (limited) understanding after reading the OP.

    c:\@Work\Perl\monks>perl -wMstrict -le "for my $s (qw(a_________ %%a_____%% 123456789_)) { print qq{'$s' matches} if $s =~ /[[:alnum:]]+[_]+/; } " 'a_________' matches '%%a_____%%' matches '123456789_' matches

    Update 1: And what about the  { } curlies?

    Update 2: And please use code tags when you post. Please see Writeup Formatting Tips and Markup in the Monastery.


    Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2023-12-02 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (18 votes). Check out past polls.

    Notices?