Should I escape closing brackets characters (that is, ]
, }
and )
) in Perl and ECMAScript-compatible regular expressions flavors?
It looks from the answer for this question that I must not escape ]
bracket but I do must to do this in case of }
and )
(for PCRE). Of course, I must escape them if I want to use them inside the corresponding regular expressions sequences like (first\)|second)
or [ab\]]
but what about other cases?
For example, should I escape them in the following case?
Regular expression -- str\[]
Input string -- str[]