Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: constants in an RE

by BillKSmith (Monsignor)
on May 15, 2023 at 21:30 UTC ( [id://11152198] : note . print w/replies, xml ) Need Help??

in reply to constants in an RE

Using Unicode Character names (Creating Unicode) avoids your problem. It has the further advantage that it eliminates confusion between similar looking characters.
use strict; use warnings; use utf8; use Test::More tests=>1; my $string = "wjzwxl cowuxze."; my $required = "wjzw\N{APOSTROPHE}xl cowuxze."; #"wjzw'xl cowuxze. +"; $string =~ s/\N{RIGHT SINGLE QUOTATION MARK}/'/ ; is( $string, $required, 'APOSTROPHE' );

UPDATE: Added link