0

I'm not sure why the following is giving me a PatternSyntaxException:

Pattern regex = Pattern.compile("\\[[12|\\[|\\|\\||\\^\\^|\\^|\\_|\\_\\_|\\=|abcdefgABCDEFG|\\|");  

It claims the error is at |a which I don't really understand.

0

2 Answers 2

2

I don't see a matching ']' to the one that isn't escaped...

 Pattern regex = Pattern.compile("\\[[12|...
                                     |This one
Sign up to request clarification or add additional context in comments.

Comments

0

Are the characters inside the unescaped pipes supped to be a character range? Of so, they should be in square brackets.

[A-Ga-g]

It's an error because the pipe character is a regex logical operator (or).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.