baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
i need a suggestion on how to do this in more elegant way
i have this regex that for which every line is evaluated through a while() loop. but some lines do not contain all necesery parameters for a regex to match and therefor if a parameter Positives is missing then the whole line would be skipped and that is not good. i know i could do it by splitting a line starting with a word Identities and then extract the data from it. but there are some complication that then appear and i wish to avoid that.Identities\s+=\s+(.+)\s+\((.+)\%\),\s+Positives =\s+(.+)\s+\((.+)\%\), +\s+Negatives\s+=\s+(.+)\s+\((.+)\%\)/g
so my question is: is there a more elegant way to match a line check if parameters(in this case Identities,Negatives,Positives )exists and if some are missing just ignore that and deal with ones that do exist.
thnx
Update:
That is it dreadpiratepeter !!
thnx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex question
by dreadpiratepeter (Priest) on Jul 21, 2009 at 13:12 UTC | |
|
Re: Regex question
by JavaFan (Canon) on Jul 21, 2009 at 12:59 UTC | |
|
Re: Regex question
by CountZero (Bishop) on Jul 21, 2009 at 14:38 UTC |