Reputation: 7
this is my regular expression, which I use on command line, but when I put the same expressing on java pattern.compile, it is giving an error
This is my regex /,.*"(.*)",\[6]/
This is how I am trying in java
Pattern p = Pattern.compile("/,.*"(.*)",\[6]/");
but in eclipse it is showing an error, could some one help on this.
Upvotes: 0
Views: 143
Reputation: 1538
You have to escape the double quotes (and possibly the blackslash) using backslashes.
EDIT:
It seems what you want is this
,.*\"(.+)\",\\[6\\]
You don't have to include forward slashes in patterns in Java. If you know you will have something between quotes, use +
instead of *
, and you have to escape the square brackets, because you want a literal match.
Upvotes: 1