I want the regular expression to match the square bracket [ . I haven't found it yet. I think I tried all the possibilities, but did not find the right one. What is the correct regular expression for this?
[
How to use backslash \ before square bracket. Usually square brackets correspond to a character class.
\
Try using \\[ or just \[ .
\\[
\[
Do you avoid it with \ ?
/\[/
Here's a useful resource that you can start with regular expressions:
Regular-Expressions.info
If you want to find both variants of square brackets at the same time, you can use the following template, which defines the range of the character [ or character ] : /[\[\]]/
]
/[\[\]]/
In general, when you need a character that is "special" in regular expressions, just attach it to \ . Thus, the letter [ will be \[ .
Does this work with antispas before [ ?
\[ or \\[ ?
If you want to delete [ or ] , use the expression: "\\[|\\]" .
"\\[|\\]"
Two backslashes come out of the square bracket, and the pipe is an "or".