I am writing a regex in java but i am getting an error when I run the program.
private final static Pattern QUOTE_VALUE = Pattern.compile("[_]?([a-zA-Z0-9_]+)=(\"[^]*\"),");
// Then later on down the road......
Macher m = QUOTE_VALUE.matcher(myString);
while (m.find()){
System.out.println("Found " + m.group(1) + " " + m.group(2));
}
I want to make my regex to match these sample values.
_MyKey="ID IN [ "ABC" ]", // Note - it has a comma after the ]
_MyKey="ID IN [ ""XYZ"" ]", // Note - it has a comma after the ]
I tried it with online regex helper - and my regex actually works fine. But when I run the program in , i get this error:
Caused by: java.util.regex.PatternSyntaxException: Unclosed character class near index 28
[_]?([a-zA-Z0-9_]+)=("[^]*"),
Another question is, how do i format the regex so i can also match it with this String?
MyKey="ID IN [ "ABC" ]", // without the _
_MyKey="ID IN [ "ABC" ]", // with the _
Thanks.
[EDIT]
Can you help me with this part of question?
Another question is, how do i format the regex so i can also match it with this String?
MyKey="ID IN [ "ABC" ]", // without the _ _MyKey="ID IN [ "ABC" ]", // with the _
[^]x]as an example that may explain your error well.