Regular Expression: Double Backslashes in Bracket Expression
regex
Solution
Here is a link to your regular expression along with some example test strings, as tested in Rubular.
The `^` at the start of your regular expression anchors what you are about to match for to the beginning of your test string.
Following that is brackets `[]`, which means any of the characters within the brackets can be matched for.
Inside the brackets, you have a `\\` - the first `\` escapes the character that is following - meaning you want to search for whatever is about to follow that `\`. It just so happens that what follows is another `\` - so that means one of the characters you will accept is a `\`.
Following that is a question-mark `?` - which, when placed inside brackets, literally means you want to match for the question-mark symbol.
So, your regular expression is looking for any string that begins with either a backslash or a question-mark.
Again, please reference the example test strings at Rubular.
Problem
What do the double backslashes in the following expression match? ``` /^[\\?]/ ``` Is it a filter for `\` and `&` (escaped backslash) - or - `\\` and `&` (not escaped) - or - `\` and `?` (escaped question mark)?