"^\\\\d{1,2}$"
I have the above regex. I know that the string parser will remove two backlashes leaving us with \\d. Taking one for the meta-character, what is the function of the extraneous \ ? I haven't had previous experience in regex. Or is the string pattern is in itself [backslash][integer up to two occurences]. Am I missing something ?
Backslashes escape other backslashes, as well as special characters.
What you have there is:
\d is "digit", in your regex engine.\\d is backslash-escaping-backslash + d, == \d, in your string quoting mechanism.\\\\d is backslash-escaping-backslash, twice, +d, probably escaping the command line if you're using a shell, or if you have to pass the string through system or rsh or something.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With