in reply to A query on greedy regexps
Greedy operators, as explained by broquaint, gobble up as much of the input text as possible that still allows the regex to match. AIUI, if the match fails, perl's regular expression engine will force one character (unicode aside) from the text matched by the .* to be "given back", to see if the rest of the expression can match. (Caveat: I've realised I need to read O'Reilly's "Mastering Regular Expressions" again, so this might well be wrong.)
Looking at the regex you've created, I can't see any advantage to making the quantifiers non-greedy - they all need to match to the end of the line anyway.
If you're looking for a robust solution, then, as I mentioned in the CB, I'd recommend installing HPUX::Ioscan and using that, or at least looking at the code to see how it does it. (Hint: It does it by looping over each line)
Summary: I think your regex is fine (although you forgot the "Class\n======\n" header at the start of your example output, so the regex won't work), although I'd still advocate using the module
cheers
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A query on greedy regexps
by sch (Pilgrim) on Oct 01, 2002 at 12:29 UTC |