Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: regex extraction for variable number of args

by Corion (Patriarch)
on Jul 22, 2012 at 07:15 UTC ( [id://983041]=note: print w/replies, xml ) Need Help??


in reply to Re^4: regex extraction for variable number of args
in thread regex extraction for variable number of args

I can think of many uses for non-capturing parentheses with repetition. In fact, non-capturing parentheses with repetition are more sane than capturing parentheses with repetition, because the capturing parentheses will only keep the last match of the repetition. As an example a simple checker to check that a line matches a CSV-like format, using non-capturing parentheses and repetition:

$line =~ /^(?:[^,]+|"[^"]+")(?:,(?:[^,]+|"[^"]+"))*$/

That one matches one well-formed column, and then optionally a repetition of comma and more well-formed column.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-24 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found