bingohighway has asked for the wisdom of the Perl Monks concerning the following question:
I have a bit more of a complicated regex which I am stuck with. User types in the string to be matched, e.g. toilet(32), and this should then be whacked into a regex to match to a variable.
I know the brackets are causing a problem, so the input string should go from /toilet(32)/ to this /toilet\(32\)/so the regex can function properly. Can anyone help me witha substitution regex to scan this string and prepend all non-complying characaters with "\".
Also, some of the strings will actually be some code, with the regex inside.e.g.
Should be:$line = 'if($appliance =~ /toilet(32)/)';
If that makes sense :-) Cheers$line = 'if($appliance =~ /toilet\(32\)/)';
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex help
by Anonymous Monk on May 06, 2009 at 11:12 UTC | |
by moritz (Cardinal) on May 06, 2009 at 11:23 UTC | |
by ccn (Vicar) on May 06, 2009 at 11:31 UTC | |
by moritz (Cardinal) on May 06, 2009 at 11:53 UTC | |
by ikegami (Patriarch) on May 06, 2009 at 15:21 UTC | |
by bingohighway (Acolyte) on May 06, 2009 at 12:19 UTC | |
by bingohighway (Acolyte) on May 06, 2009 at 11:51 UTC | |
Re: Regex help
by planetscape (Chancellor) on May 07, 2009 at 03:32 UTC | |
Re: Regex help
by JavaFan (Canon) on May 06, 2009 at 11:36 UTC | |
Re: Regex help
by vinoth.ree (Monsignor) on May 06, 2009 at 13:19 UTC | |
by bingohighway (Acolyte) on May 06, 2009 at 13:34 UTC | |
Re: Regex help
by bichonfrise74 (Vicar) on May 06, 2009 at 22:57 UTC |