in reply to Re^3: perl regex to match newline followed by number and text
in thread perl regex to match newline followed by number and text
it might be one or two or three or more newlines in the last fieldWell it'd be nice if your sample data would reflect that. Anyhow. I'd solve this using a simple algorithm rather than a complicated regex that backtracks god knows how often with all these .*
Outputuse warnings; use strict; my @record; while (<DATA>) { if (/^\d+\~/ && @record) { print join (" ", @record), "\n"; @record = (); } chomp; push @record, $_; } print join (" ", @record), "\n"; __DATA__ 99~Markus~Holli~Mobilenum: 1234-567 , from Earth Europe White Human 98~Mahesh~Babu~Mobilenum: 5678-901 , from Earth India Brown Human
99~Markus~Holli~Mobilenum: 1234-567 , from Earth Europe White Human 98~Mahesh~Babu~Mobilenum: 5678-901 , from Earth India Brown Human
|
|---|