Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
But this only returns the penultimate charcter block before the newline The last block is followed by a newline, not a blank, while in your regex there is a space trailing the block, so it does not match. Next problem, it only returns a single block because you match the entire string at once, but capture into always the same parens. So after one single iteration you have "eaten" the entire string, but you only get the last paren content. Update: Checking for a UFOFH at the start of the line then splitting on blanks as suggested is a probably the easiest and most robust solution, but you can do it with just regexen:
The \G is an anchor kind of like ^, except it does not match at the beginning of the string, but at the point where the previous /g match ended. As you see, it is slightly complicated to do this without split.. Update: I have a ways yet to go, obviously. The above solution bugged me, just slightly but it did. It took a day until I realized how to do it well - or more like, slap my forehead and say "D'oh".. This is the real thing (until further notice..): ____________ Makeshifts last the longest. In reply to Re: Regex matching
by Aristotle
|
|