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.
In reply to Re: Regex on a variable with special characters
by hippo
in thread Regex on a variable with special characters
by jaydee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |