in reply to Re^3: regex in REPLACEMENT in s///
in thread regex in REPLACEMENT in s///
Could this be (sensibly) rewritten without the parenthesis? $example =~ s/hiss(es)?/leak/;
Although tybalt89 probably can think of some ways, my answer would be: No, I would keep the parentheses in that case. However, they can be made non-capturing by writing /hiss(?:es)?/ (or with the /n modifier, new since 5.22). I think choroba's point was that in s/(\d)/3/g, the parens serve no purpose at all.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: regex in REPLACEMENT in s///
by Bod (Parson) on Sep 13, 2023 at 10:42 UTC |