in reply to Regex on a variable with special characters
I am trying to see if $y starts with $x, but $y sometimes contains regex special characters ...
Then you have no problem - your current regex is fine. It is only if $x has regex special characters that you need to worry.
If $x is just a literal string rather than a regular expression per se, consider using index instead. Less error-prone and (usually) faster too.
|
|---|