But that has the defects that you have to know you'll only ever have one modifier in $RegEx, and that it doesn't do case-insensitive matching. What we need to be able to do is use variables as regex modifiers - but I don't think we can. Or can we?$String =~ /(??{substr($RegEx,1,-2)})/;
Of course, this doesn't allow for global and continuous global matching, but that way madness lies...($x,$s,$m) = split(/\//,$RegEx); sub p {print "Match: ",$&||"none"," Pre: ",$`||"none"," Post: ",$'||"n +one","\n"} if ($m eq 'i') {$String =~ /$s/i;p} if ($m eq 'm') {$String =~ /$s/m;p} if ($m eq 's') {$String =~ /$s/s;p} if ($m eq 'x') {$String =~ /$s/x;p} if ($m eq 'o') {$String =~ /$s/o;p} if ($m eq 'im') {$String =~ /$s/im;p} if ($m eq 'is') {$String =~ /$s/is;p} if ($m eq 'ix') {$String =~ /$s/ix;p} if ($m eq 'io') {$String =~ /$s/io;p} if ($m eq 'mis') {$String =~ /$s/mips;p} if ($m eq 'mix') {$String =~ /$s/mix;p} if ($m eq 'mio') {$String =~ /$s/mio;p} if ($m eq 'smix') {$String =~ /$s/smix;p} if ($m eq 'smio') {$String =~ /$s/smio;p} if ($m eq 'xsmio') {$String =~ /$s/xsmio;p}
In reply to Re: Applying a RegEx in a variable
by George_Sherston
in thread Applying a RegEx in a variable
by ChOas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |