Re: Removing ' characters

2022-01-10 Thread ToddAndMargo via perl6-users
On 1/10/22 07:41, Richard Hainsworth wrote: If a string is enclosed in ' characters, and I want to remove the bracketing ', how do I do it? Seems like ' is not a normal character, or is it because its not a bracketing character? Using REPL I got > my $s = '\'\'' '' > $s.subst( / \' ~ \'

Re: Removing ' characters

2022-01-10 Thread William Michels via perl6-users
Hi Richard, In a script: my $s = '\'\''; $s.subst( / "'" ~ "'" (.+) /, {$0}).put; put s/ \< .+ \/ \> /$// given $s; put s/ \' <( .+ )> \' /$// given $s; #all three return: HTH, Bill. On Mon, Jan 10, 2022 at 8:46 AM Simon Proctor wrote: > > Within the regex the ' character is just another

Re: Removing ' characters

2022-01-10 Thread Simon Proctor
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 = "''"; or $s = q['']; both work. On

Re: Removing ' characters

2022-01-10 Thread Richard Hainsworth
Aha. Thanks On 10/01/2022 15:59, Gianni Ceccarelli wrote: On Mon, 10 Jan 2022 15:41:04 + Richard Hainsworth wrote: Using REPL I got > my $s = '\'\'' '' > $s.subst( / \' ~ \' (.+) /, $0) Use of Nil in string context   in block at line 1 That error message (which is a bit LTA)

Re: Removing ' characters

2022-01-10 Thread Gianni Ceccarelli
On Mon, 10 Jan 2022 15:41:04 + Richard Hainsworth wrote: > Using REPL I got > > > my $s = '\'\'' > '' > > $s.subst( / \' ~ \' (.+) /, $0) > Use of Nil in string context >   in block at line 1 That error message (which is a bit LTA) refers to the `$0`. As

Removing ' characters

2022-01-10 Thread Richard Hainsworth
If a string is enclosed in ' characters, and I want to remove the bracketing ', how do I do it? Seems like ' is not a normal character, or is it because its not a bracketing character? Using REPL I got > my $s = '\'\'' '' > $s.subst( / \' ~ \' (.+) /, $0) Use of Nil in string context   in