Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Matching a keyword, value and optional comma delimited values

by BooK (Curate)
on Dec 22, 2000 at 04:39 UTC ( [id://47979]=note: print w/replies, xml ) Need Help??


in reply to Matching a keyword, value and optional comma delimited values

You can try those:
  • if you have not more than 3 optional values:
    # match everything at once @everything = /^\s*(\w+)\s*=\s*(\w+)(\s*,\s*\w+)?(\s*,\s*\w+)?(\s*,\s* +\w+)?$/
  • if you can have any number of optional values, you have to use \G (explained in perlop and perlre)
    # match the required part /^\s*(\w+)\s*=\s*(\w+)/gc; ($keyword, $value) = ($1,$2); # match the optional part @optional = /\G\s*,\s*(\w+)/g;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2025-06-21 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.