in reply to Splitting string based on potentially escaped character
You could use a compiled regexp:
Output:perl -E ' my $x = "foo+bar+baz"; my $y = "+"; my $z = qr/\Q$y\E/; say for split $z, $x; '
... but why not just use:foo bar baz
in all cases? (There's probably a reason; I don't know it.)say for split /\Q$y\E/, $x;
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Splitting string based on potentially escaped character
by clamport (Initiate) on Mar 07, 2017 at 18:52 UTC |