Solo has asked for the wisdom of the Perl Monks concerning the following question:
recordID: blah fieldname: value foo : bar : baz ...
With the regular expression like so:
while ( /\G\s*([^:]+?)\s*:\s*(.+?)?\s*$/mg ) {...}
My problem is that sometimes value is empty and I'm matching the whole next line, rather than not matching the optional (.+?)?. I haven't used /s, so I thought .+ wouldn't match a newline, but it seems to be. What am I missing?
TIA!
--Solo
--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex problem with .+ matching newlines without /s
by ccn (Vicar) on Aug 31, 2004 at 17:40 UTC | |
|
Re: Regex problem with .+ matching newlines without /s
by ysth (Canon) on Aug 31, 2004 at 18:15 UTC | |
by Solo (Deacon) on Aug 31, 2004 at 18:55 UTC | |
|
Re: Regex problem with .+ matching newlines without /s
by sleepingsquirrel (Chaplain) on Aug 31, 2004 at 19:45 UTC | |
by Aristotle (Chancellor) on Aug 31, 2004 at 21:40 UTC |