Text processing/2: Difference between revisions

Content added Content deleted
m (→‎{{header|Sidef}}: modified the code to work with Sidef 2.30)
Line 2,895: Line 2,895:
// I can't use it to select all fields, only verify them
// I can't use it to select all fields, only verify them
re:=RegExp(0'|^(\d+-\d+-\d+)| + 0'|\s+\d+\.\d+\s+-*\d+| * 24 + ".+$");
re:=RegExp(0'|^(\d+-\d+-\d+)| + 0'|\s+\d+\.\d+\s+-*\d+| * 24 + ".+$");
w:=Utils.Helpers.zipW(File("readings.txt"),[1..]); //-->lazy (line,line #)
w:=[1..].zip(File("readings.txt")); //-->lazy (line #,line)
reg datep,N, good=0, dd=0;
reg datep,N, good=0, dd=0;
foreach line,n in (w){
foreach n,line in (w){
N=n; // since n is local to this scope
N=n; // since n is local to this scope
if (not re.search(line)){ println("Line %d: malformed".fmt(n)); continue; }
if (not re.search(line)){ println("Line %d: malformed".fmt(n)); continue; }