Skip to content

Commit b839ace

Browse files
authored
start section on substitution RHS restrictions
More specifics need to be added.
1 parent 9fc140b commit b839ace

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

doc/Language/regexes.pod6

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,8 +1610,21 @@ backslash C<\> or included in quotes:
16101610
s/Space\:/Party like it's/;
16111611
.say # OUTPUT: «Party like it's 1999␤»
16121612
1613-
Note that the matching restrictions only apply to the left-hand side of the
1614-
substitution expression.
1613+
Note that the matching restrictions generally only apply to the left-hand side of the
1614+
substitution expression, but some special characters or combinations of them may need
1615+
to be escaped. For example
1616+
1617+
$_ = 'foo';
1618+
s/foo/\%(/;
1619+
.say # OUTPUT: <<%(\n>>
1620+
1621+
or escape the '(' instead for the same result
1622+
1623+
s/foo/%\(/;
1624+
.say # OUTPUT: <<%(\n>>
1625+
1626+
but using either character alone does not require escaping. Forward slashes will need
1627+
to be escaped, but escaping alphanumeric characters will cause them to be ignored.
16151628
16161629
By default, substitutions are only done on the first match:
16171630

0 commit comments

Comments
 (0)