Just another Perl shrine | |
PerlMonks |
Matching a keyword, value and optional comma delimited valuesby brainpan (Monk) |
on Dec 22, 2000 at 01:21 UTC ( [id://47919]=perlquestion: print w/replies, xml ) | Need Help?? |
brainpan has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to match a string like the following: keyword = value, optional1, optional2, optional3 where only keyword and value are required, and there are zero or more optional parameters. So far all I've been able to come up with is /^(\w+)\s*=\s*(\w+)([,[\s\w]*]*)$/ The above regex works, but it seems like I should be able to have $3 return without commas in it. Is there a way to do this w/out resorting to using something like join(' ', split(/,/, $3)) to process the results of the regex?
Back to
Seekers of Perl Wisdom
|
|