in reply to Re: Regex stored in a scalar
in thread Regex stored in a scalar
A regex should be between / / marks ...
The =~ operator is sufficiently DWIMic that it will take any string as a regex. It will even take all the qr// regex modifiers if they are embedded as (?adlupimsx-imsx) extended patterns.
c:\@Work\Perl>perl -wMstrict -le "my $regex = '(?xms) ((.) \2{2,})'; ;; for my $s (qw(aeiou aeeiou aeiiiou aeioooou)) { print qq{match: captured '$1'} if $s =~ $regex; } " match: captured 'iii' match: captured 'oooo'
... but that won't work ...
The first comment I made is actually rather trivial in the face of your second point; the substitution s/\),\(/\)\n\(/ is, indeed, a substitution and not a regex — and bang, the whole endeavor hits a brick wall.
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex stored in a scalar
by Laurent_R (Canon) on Aug 22, 2015 at 16:17 UTC |