in reply to Dynamic Regular Expression
What have you tried? How did it fail? What specific detail are you having trouble with? See I know what I mean. Why don't you?. As a starting point you may find it helps to refactor your expression as:
use strict; use warnings; my @opts = qw(K1 ASC GEB N1); my $alts = join '|', @opts; my $re = qr{^(?:$alts)_(\w*\d*)$}; print "Matched $1\n" if 'GEB_S1' =~ $re;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dynamic Regular Expression
by Pratikh (Initiate) on Jan 06, 2021 at 15:56 UTC |