Re: regex: how to I pick out items in the middle?

2022-10-29 Thread William Michels via perl6-users
On Sat, Oct 29, 2022 at 7:29 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > >> On Sat, Oct 29, 2022 at 6:46 PM ToddAndMargo via perl6-users > >> mailto:perl6-users@perl.org>> wrote: > >> > >> Hi All, > >> > >> With a regex, how do I pick out items in the middle of the

Re: regex: how to I pick out items in the middle?

2022-10-29 Thread ToddAndMargo via perl6-users
On Sat, Oct 29, 2022 at 6:46 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, With a regex, how do I pick out items in the middle of the string? Two from the beginning or two from the end? 4] > my Str $y="xx"; $y ~~ s/ $([.*-2]) "x"/Q/; print

Re: regex: how to I pick out items in the middle?

2022-10-29 Thread William Michels via perl6-users
In the Raku REPL: $ raku Welcome to Rakudo™ v2022.07. Implementing the Raku® Programming Language v6.d. Built on MoarVM version 2022.07. To exit type 'exit' or '^D' [0] > #beginning Nil [1] > my Str $y="xx"; S/^ x ** 2 /QQ/.say given $y; QQ [1] > #inner Nil [2] > my Str $y="xx"; S/^

regex: how to I pick out items in the middle?

2022-10-29 Thread ToddAndMargo via perl6-users
Hi All, With a regex, how do I pick out items in the middle of the string? Two from the beginning or two from the end? 4] > my Str $y="xx"; $y ~~ s/ $([.*-2]) "x"/Q/; print $y ~ "\n" ===SORRY!=== Error while compiling: Malformed postfix call --> my Str $y="xx"; $y ~~ s/

Re: how do I do a literal string in the target of a regex?

2022-10-29 Thread ToddAndMargo via perl6-users
On 10/29/22 14:28, ToddAndMargo via perl6-users wrote: On 10/29/22 13:07, Elizabeth Mattijsen wrote: > $ echo "a/b/c/d" | raku -ne 'say .subst("/", Q/\\\/, :g)' > Hi Elizabeth, Thank you for the subst workaround! I created a keep of the subst. Got to love Raku. 101 ways of doing

Re: how do I do a literal string in the target of a regex?

2022-10-29 Thread ToddAndMargo via perl6-users
On 10/29/22 13:02, ToddAndMargo via perl6-users wrote: Hi All, I am trying to change / into \\\ This works: $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|\\|;print $x ~ "\n"' a\\\b\\\c\\\d But this does not: $ echo "a/b/c/d" | raku -ne 'my $x=$_;

Re: how do I do a literal string in the target of a regex?

2022-10-29 Thread ToddAndMargo via perl6-users
On 29 Oct 2022, at 23:28, ToddAndMargo via perl6-users wrote: On 29 Oct 2022, at 22:02, ToddAndMargo via perl6-users wrote: Hi All, I am trying to change / into \\\ This works: $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|\\|;print $x ~ "\n"' a\\\b\\\c\\\d

Re: how do I do a literal string in the target of a regex?

2022-10-29 Thread Elizabeth Mattijsen
/ 'literal string in target' / > On 29 Oct 2022, at 23:28, ToddAndMargo via perl6-users > wrote: > > >>> On 29 Oct 2022, at 22:02, ToddAndMargo via perl6-users >>> wrote: >>> >>> Hi All, >>> >>> I am trying to change >>> >>> / >>> >>> into >>> >>> \\\ >>> >>> This works: >>>

Re: how do I do a literal string in the target of a regex?

2022-10-29 Thread ToddAndMargo via perl6-users
On 29 Oct 2022, at 22:02, ToddAndMargo via perl6-users wrote: Hi All, I am trying to change / into \\\ This works: $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|\\|;print $x ~ "\n"' a\\\b\\\c\\\d But this does not: $ echo "a/b/c/d" | raku -ne 'my $x=$_;

how do I do a literal string in the target of a regex?

2022-10-29 Thread ToddAndMargo via perl6-users
Hi All, I am trying to change / into \\\ This works: $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|\\|;print $x ~ "\n"' a\\\b\\\c\\\d But this does not: $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|Q[\\\]|;print $x ~ "\n"' aQ[\]bQ[\]cQ[\]d How do I