On 1/30/21 5:52 PM, Joseph Brenner wrote:
I think ToddAndMargo was thinking of perl5 regexes, where [.] is
a good way of matching a literal dot-- though myself, I'm more
inclined to use \.

In Raku, the square brackets just do non-capturing grouping
much like (?: ... } in perl5.  To do a character class, you need
angles around the squares.  This would work to match a single dot:

   <[.]>

In Raku regexes a \. would also work to match a literal dot.
Until I saw JJ Merelo's post, I don't think I realized that
you could quote a meta-character using quotes:  "."

Which means there's some potential confusion if you really need
to match quotes:

     my $str = 'string_632="The chicken says--", voice="high"';

     say
       $str ~~ m:g{ ( " .*? " ) };   # False

     say
       $str ~~ m:g{ ( \" .*? \" ) };  # let's feed another quote: "  to
an emacs syntax highlighting bug
      # 「"The chicken says--"」
      # 0 => 「"The chicken says--"」 「"high"」
      #  0 => 「"high"」)


 Hi Joseph,

I am coming from Perl 5 and sed.

I simply use a single quote.  These are from actual code:

    $NewRev ~~ s/ '<' .* //;

    ( my $x = $NewRev ) ~~ s:global/ '.' //;   # remove the  dots

( my $y = $NewRev ) ~~ s:global/ '.' /_/; # replace the dots with underscores

    $ClickHere ~~ s| .*? 'a href="' ||;
    $ClickHere ~~ s| '"' .* ||;

Same as Perl 5 and sed

-T



Reply via email to