Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Java routine constructs Perl logical expression from user input to be used in another system. Java application calls a small Perl script to validate the expression. These logical expressions contain =~ type comparisons. The validation of the proper use of a dollar sign ($) inside the regular expression is being complicated by Perl variable expansion. The Perl validation routine does detect an improper use of a $ in a regular expression when the variable substitution doesn't find a defined variable, but it misses those cases when it does, i.e., $$, $1, $2, etc. For example this is an improper regular expression /^Money$1/ the dollar should have been escaped, but Perl thinks it's fine after substituting the command line variable into it.
I need a way to disable the variable expansion, while preserving the interpretation of regular expression metacharacters.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Disabling Variable Expansion in regular expressions.
by Corion (Patriarch) on May 23, 2019 at 14:33 UTC | |
|
Re: Disabling Variable Expansion in regular expressions.
by davido (Cardinal) on May 23, 2019 at 15:29 UTC | |
|
Re: Disabling Variable Expansion in regular expressions. (single quotes as delimiters)
by LanX (Saint) on May 23, 2019 at 16:11 UTC | |
by LanX (Saint) on May 23, 2019 at 16:28 UTC | |
by Anonymous Monk on May 23, 2019 at 20:16 UTC | |
by Anonymous Monk on May 23, 2019 at 18:57 UTC |