G'day roho,

I see you've got a solution using quotemeta. Here's some additional information.

A '\C' used to match a single byte. Last documented in "perlrebackslash v5.22.4: All the sequences and escapes".

It was removed in v5.24 according to "perl5240delta: The /\C/ character class has been removed."; however, although documented as such, [perl #41916] indicates this didn't happen until v5.26.

Use of '\C' is now fatal in regexes (as you've found out) and gives a warning in strings:

$ perl -wE 'say "p" =~ /\C0/ ? "Y" : "N"' \C no longer supported in regex; marked by <-- HERE in m/\ <-- HERE C0 +/ at -e line 1. $ perl -wE 'say "\C0"' Unrecognized escape \C passed through at -e line 1. C0

Probably also worth a mention is the lowercase '\c'.

It's documented, with a fair amount of detail, in "perlop: Quote and Quote-like Operators: Note 5".

Some restrictions on its use were introduced in v5.20 — see "perl5200delta: Quote-like escape changes".

Depending on what character follows '\c', you may get a warning with useful information.

$ perl -wE 'say "\c0"' "\c0" is more clearly written simply as "p" at -e line 1. p $ perl -wE 'say "p" =~ /\c0/ ? "Y" : "N"' "\c0" is more clearly written simply as "p" in regex; marked by <-- HE +RE in m/\c0 <-- HERE / at -e line 1. Y

[I used Perl v5.36 for all of the example code above.]

— Ken


In reply to Re: Unexpected Error: \C no longer supported in regex by kcott
in thread Unexpected Error: \C no longer supported in regex by roho

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.