jaydee has asked for the wisdom of the Perl Monks concerning the following question:
and I am trying to see if $y starts with $x, but $y sometimes contains regex special characters like ()[], also ** which can give me errors.$x = "SERVER-NAME";
How can I safely check if $x at the start of $y?
is the current regex I am using.$y =~ /^$x/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex on a variable with special characters
by haukex (Archbishop) on Jul 22, 2016 at 08:47 UTC | |
by jaydee (Initiate) on Jul 22, 2016 at 09:02 UTC | |
by Linicks (Scribe) on Jul 23, 2016 at 17:31 UTC | |
|
Re: Regex on a variable with special characters
by hippo (Archbishop) on Jul 22, 2016 at 09:12 UTC | |
|
Re: Regex on a variable with special characters
by Anonymous Monk on Jul 22, 2016 at 21:54 UTC | |
by Anonymous Monk on Jul 23, 2016 at 23:21 UTC | |
by Anonymous Monk on Jul 24, 2016 at 10:18 UTC |