in reply to Re^3: splinting a line of text by comma
in thread splinting a line of text by comma
if you find a way to escape curlies and other "wildcard characters"
Sure, just move them out of the way :)
#!/usr/bin/perl # https://perlmonks.org/?node_id=1226189 use strict; use warnings; #print glob qq("$_") =~ s/[^|\n]+/{$&}/gr while <DATA>; print map tr/\1-\7/{}[]"*?/r, glob +('"' . tr/{}[]"*?/\1-\7/r . '"') =~ s/[^|\n]+/{$&}/gr while <DATA>; __DATA__ some text foo | some text BAR | oh , no , commas | some text BAZ | som +e text QUX some,text,FOO{3} | some text BAR*? | "one" two | some , text , QUX
Outputs:
some text foo | some text BAR | oh | some text BAZ | some text QUX some text foo | some text BAR | no | some text BAZ | some text QUX some text foo | some text BAR | commas | some text BAZ | some text QUX some| some text BAR*? | "one" two | some some| some text BAR*? | "one" two | text some| some text BAR*? | "one" two | QUX text| some text BAR*? | "one" two | some text| some text BAR*? | "one" two | text text| some text BAR*? | "one" two | QUX FOO{3} | some text BAR*? | "one" two | some FOO{3} | some text BAR*? | "one" two | text FOO{3} | some text BAR*? | "one" two | QUX
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: splinting a line of text by comma
by LanX (Saint) on Nov 26, 2018 at 15:27 UTC |