Hi Richard, In a script:
my $s = '\'<favicon />\''; $s.subst( / "'" ~ "'" (.+) /, {$0}).put; put s/ \< .+ \/ \> /$// given $s; put s/ \' <( .+ )> \' /$// given $s; #all three return: <favicon /> HTH, Bill. On Mon, Jan 10, 2022 at 8:46 AM Simon Proctor <simon.proc...@gmail.com> wrote: > > Within the regex the ' character is just another string so rather than > escaping it you can write the regex as : > > $s.subst( / "'" ~ "'" (.+) /, $0) > > (That's " ' " (without spaces) to be exact.) And it does the trick. > > You can do the same when defining it $s = "'<favicon />'"; or $s = > q['<favicon />']; both work. > > > On Mon, 10 Jan 2022 at 16:12, Richard Hainsworth <rnhainswo...@gmail.com> > wrote: >> >> Aha. Thanks >> >> On 10/01/2022 15:59, Gianni Ceccarelli wrote: >> > On Mon, 10 Jan 2022 15:41:04 +0000 >> > Richard Hainsworth <rnhainswo...@gmail.com> wrote: >> > >> >> Using REPL I got >> >> >> >> > my $s = '\'<favicon />\'' >> >> '<favicon />' >> >> > $s.subst( / \' ~ \' (.+) /, $0) >> >> Use of Nil in string context >> >> in block <unit> at <unknown file> line 1 >> > That error message (which is a bit LTA) refers to the `$0`. As >> > https://docs.raku.org/routine/subst#Callable shows, you need to write: >> > >> > $s.subst( / \' ~ \' (.+) /, { $0 }) >> > >> >> > my $t = '{<favicon />}' >> >> {<favicon />} >> >> > $t.subst( / \{ ~ \} (.+) /, $0) >> >> <favicon /> >> > This only appear to work because you're running it in the same REPL >> > session; the previous `subst` had the side-effect of setting `$0` >> > (well, it sets `$/`, but `$0` is an alias for `$/[0]`…) >> > > > > > -- > Simon Proctor > Cognoscite aliquid novum cotidie > > http://www.khanate.co.uk/