<a href="mailto:[email protected]?in-reply-to=<
cafakbwhn7crfsov60mr9tf4vus1duv4cnqohbbdyx-awoxw...@mail.gmail.com>&subject=Re:%20Re:
delimiters with more than one character? ...">[email protected]
</a>
I've slowly been learning the Raku programming language (AKA Perl6), and
while I'm far from being an expert, this is the first solution I came up
with (raku one-or-two-liners, at the bash command prompt):
user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ";
$s.put';
34 + 45 | abc | 1 2 3 | c|123abc
user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ";
$s.split("|").raku.put';
(" 34 + 45 ", " abc ", " 1 2 3 ", " c", "123abc ").Seq
user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ";
.put for $s.split("|");'
34 + 45
abc
1 2 3
c
123abc
user@mbook:~$ raku -e ' my Str $s=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ";
.raku.put for $s.split("|");'
" 34 + 45 "
" abc "
" 1 2 3 "
" c"
"123abc "
user@mbook:~$
Looking at the Str typed-variable $s I see that backslash escapes are
removed automatically (the second command only has to split on the pipe
character). So maybe this isn't a general solution, but it works for the
example given.
https://raku.org/
HTH, Bill.
(Apologies if this message gets threaded improperly).