Would someone kindly demonstrate what the regular expession would be for matching the square brackets?
I'm currently using java.util.regex
.
For example, let's say we have the following line:
public static void main (String[] args) {
I need to match only the OPEN square bracket [
and next, the close square bracket ]
.
I'm not saying I need to match the text between the square brackets.
I have tried with
[\\]]
and
\\]
Unfortunately, it matches the text as well and I need to match only [
or ]
.
The weird thing is, when I try to match the {
with [\\}]
, it works!
Thoughts?