What's the regular expression that matches a square bracket?
How about using backslash \
in front of the square bracket. Normally square brackets match a character class.
Try using \\[
, or simply \[
.
If you want to match an expression starting with [
and ending with ]
, use \[[^\]]*\]
.