develooper Front page | perl.perl6.users | Postings from January 2022

Removing ' characters

Thread Next
From:
Richard Hainsworth
Date:
January 10, 2022 15:41
Subject:
Removing ' characters
Message ID:
c104c493-6d25-fe6b-f700-da7cc7731ef2@gmail.com
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 = '\'<favicon />\''
'<favicon />'
 > $s.subst( / \' ~ \' (.+) /, $0)
Use of Nil in string context
   in block <unit> at <unknown file> line 1

 > my $t = '{<favicon />}'
{<favicon />}
 > $t.subst( / \{ ~ \} (.+) /, $0)
<favicon />


For clarity

raku -v

Welcome to Rakudo™ v2021.12.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2021.12.



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About