in reply to regex compilation
/$regex2/ will have the same interpolation as qr/$regex2/, so we can look more closely at what you are getting by examining the resulting regex2 object:
my $regex1 = qr/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; my $regex2 = qq/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; print $regex1, "\n", qr/$regex2/, "\n";
The output:
(?^:(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))) (?^:(?:(?|(?:")([^\"]*(?:\.[^\"]*)*)(?:"))))
The single quoted construct is gobbling the escapes.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex compilation
by AnomalousMonk (Archbishop) on Feb 12, 2019 at 20:29 UTC | |
|
Re^2: regex compilation
by morgon (Priest) on Feb 12, 2019 at 18:05 UTC | |
by AnomalousMonk (Archbishop) on Feb 12, 2019 at 18:31 UTC | |
by Laurent_R (Canon) on Feb 12, 2019 at 18:51 UTC |