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
    I had the same idea° but that's not really "escaping".

    And for a general purpose solution you would need to escape \1..\7 too. I'm afraid that's not feasible with tr.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

    °) using this technique in my Wiki-nodelet-hack already