Hi!
I have been playing with JFlex and at this moment I want to get a regex that match a square bracket "[", but I don't find it. I think I tried all posivilities but the right.
Some help?
views:
2256answers:
6
+5
A:
How about using backslash (\) in front of the square bracket. Normally square brackets match a character class.
Peter Stuifzand
2009-05-29 20:51:01
+1
A:
Are you escaping it with "\"?
/\[/
Here's a helpful resource to get started with Regular Expressions:
sirlancelot
2009-05-29 20:52:24
A:
In general, when you need a character that is "special" in regexes, just prefix it with a \
. So a literal [
would be \[
.
Zifre
2009-05-29 20:52:30
A:
If you're looking to find both variations of the square brackets at the same time, you can use the following pattern which defines a range of either the "[" sign or the "]" sign: /[\[\]]/
Jaytop
2009-11-10 10:32:40