Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by hdb (Monsignor)
on Mar 29, 2018 at 07:54 UTC ( #1211959=note: print w/replies, xml ) Need Help??


in reply to Looking for a regular expression for the following pattern.

Groups of at least two alphanumeric characters separated by underscores:

/^(([a-zA-Z0-9]+)_)*[a-zA-Z0-9]+$/

Replies are listed 'Best First'.
Re^2: Looking for a regular expression for the following pattern.
by ikegami (Patriarch) on Mar 29, 2018 at 12:39 UTC

    That matches "1" and "a\n". It doesn't match "a_".

      Next try...

      /^(([a-zA-Z0-9]{2,}_)*[a-zA-Z0-9]{2,})$/ && print "$_\n" for "1", "a\n", "aa\n", "a_", "aa", "aa_bb_cc_dd", "a1_11_1c_11", +"aaa", "aa_";

      Still matches a trailing newline. It does not match "aa_" on purpose as this is not a sequence of two or more alphanumeric characters separated by underscores which was my claim if not the original question.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2022-05-16 19:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (63 votes). Check out past polls.

    Notices?