in reply to substitute instead global matching for nested matches
while ($fc =~ /#(\d+)\s+(([^#\s]\S*\s+\S+\s+)*)/g ) {to get it to work the way you claimed. Otherwise that first match just grabs everything up to r5.
I'm also still unclear on what sorts of things are expected on input, e.g., why is the split call using \n when the first regexp suggests that you're expecting things to be separated by general whitespace \s+ which may or may not have newlines in it (or have multiple newlines in it)?
E.g., it's possible that
join '', map {m/(\d*)\s+(?:\S+\s+\S+\s+)*(\S+\s+\S+\s+)$/ ? "#$1\n$2" : ()} split /^#/m, $fcis what you want, but I can't tell for sure.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitute instead global matching for nested matches
by utku (Acolyte) on Mar 20, 2012 at 13:56 UTC |