in reply to Re: Regular Expresssion TroubleShoot Help plz
in thread Regular Expresssion TroubleShoot Help plz
$foo = qq{^snafu^|^foobar^\n}; $foo =~ m/\A(\W) # \A instead of ^ and match first non-word .+? # +? Minimal match everything that isn't in \1 \1(\W) # Match non-word following the 2nd \1 /xms; $TEXT_QUAL = $1; $FIELD_SEP = $2;
Fails to work since the qualifiers are metacharacters used in regular expressions.$foo =~ /\G$TEXT_QUAL(.*?)$TEXT_QUAL[$FIELD_SEP\n]/xmsgc;
Fails to work as \$ is a literal $ followed by the name.$foo =~ /\G\$TEXT_QUAL(.*?)\$TEXT_QUAL[\$FIELD_SEP\n]/xmsgc;
Also Fails to work as \\ is is a literal \ The only way I've found is$foo =~ /\G\\$TEXT_QUAL(.*?)\\$TEXT_QUAL[\\$FIELD_SEP\n]/xmsgc;
$LIT_TEXT_QUAL = qq{\\$TEXT_QUAL}; $LIT_FIELD_SEP = qq{\\$FIELD_SEP}; $foo =~ /\G$LIT_TEXT_QUAL(.*?)$LIT_TEXT_QUAL[$LIT_FIELD_SEP\n]/xmsgc;
|
|---|