Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #224887

Re: delimiters with more than one character?

From William Michels <wjm1@caa.columbia.edu>
Newsgroups linux.debian.user
Subject Re: delimiters with more than one character?
Date 2020-07-16 21:10 +0200
Message-ID <Athqx-2eq-9@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

<a href="mailto:debian-user@lists.debian.org?in-reply-to=<
CAFakBwhN7crFsov60mR9tF4VUS1Duv4CNQohBBDyX-AWOXW-Kw@mail.gmail.com>&amp;subject=Re:%20Re:
delimiters with more than one character? ...">debian-user@lists.debian.org
</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).

Back to linux.debian.user | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: delimiters with more than one character? William Michels <wjm1@caa.columbia.edu> - 2020-07-16 21:10 +0200
  Re: delimiters with more than one character? Nicolas George <george@nsup.org> - 2020-07-16 21:10 +0200
    Re: delimiters with more than one character? William Michels <wjm1@caa.columbia.edu> - 2020-07-17 04:10 +0200
  Re: delimiters with more than one character? Dan Ritter <dsr@randomstring.org> - 2020-07-16 21:30 +0200
    Re: delimiters with more than one character? David Wright <deblis@lionunicorn.co.uk> - 2020-07-17 05:00 +0200
      Re: delimiters with more than one character? Dan Ritter <dsr@randomstring.org> - 2020-07-17 14:40 +0200

csiph-web