java.util.regex.PatternSyntaxException: Unmatched closing ')' : during string.split operation

Abhidemon

I am trying to perform a split similar the following:

String str = "({Somestring 1 with a lot of braces and commas}),({Somestring 12with a lot of braces and commas})";
println str.split("}),({");

But i see:

java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 0 }),({

Clearly , my string is being treated as a regular expression.

Is there a way i can escape this string?

Jens

the character ( and ) and { and } are special character in regexp. you have to escape these:

println str.split("\\}\\),\\(\\{");

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Exception in thread "main" java.util.regex.PatternSyntaxException: Unmatched closing

From Dev

Java PatternSyntaxException: Unmatched closing '('

From Dev

java.util.regex.PatternSyntaxException

From Dev

java.util.regex.PatternSyntaxException with UCanAccess

From Dev

java.util.regex.PatternSyntaxException Android

From Dev

Caused by: java.util.regex.PatternSyntaxException: Illegal repetition

From Dev

java.util.regex.PatternSyntaxException: Unclosed character class near index 0

From Dev

java.util.regex.PatternSyntaxException: Unclosed character class near index 12 \\b]([^.(|[]+)

From Dev

java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0 +

From Dev

java.util.regex.PatternSyntaxException: Unclosed character class near index 44

From Dev

Javascript regex to remove unmatched closing HTML tags?

From Dev

Java string split() Regex

From Dev

Java string split() Regex

From Dev

js split with regex will keep unmatched seperator

From Dev

java - using regex to split string

From Dev

Java regex split string not working

From Dev

Regex based string split in Java

From Dev

How to split a java string with a regex?

From Dev

java - using regex to split string

From Dev

Regex to find and fix unmatched xml closing tags in notepad++

From Dev

String split Operation based on characters in java

From Dev

How to extract the unmatched portion of a string using a regex

From Dev

Java Caching String.split Regex

From Dev

Java regex to split string with variable spaces and delimiter

From Dev

Java regex split string after number

From Dev

How to split this string in java need regex?

From Dev

Java String split with regex ignoring content in parenthesis

From Dev

How to split string by java regex with look behind?

From Dev

Java Regex to split a String with int, doubles

Related Related

  1. 1

    Exception in thread "main" java.util.regex.PatternSyntaxException: Unmatched closing

  2. 2

    Java PatternSyntaxException: Unmatched closing '('

  3. 3

    java.util.regex.PatternSyntaxException

  4. 4

    java.util.regex.PatternSyntaxException with UCanAccess

  5. 5

    java.util.regex.PatternSyntaxException Android

  6. 6

    Caused by: java.util.regex.PatternSyntaxException: Illegal repetition

  7. 7

    java.util.regex.PatternSyntaxException: Unclosed character class near index 0

  8. 8

    java.util.regex.PatternSyntaxException: Unclosed character class near index 12 \\b]([^.(|[]+)

  9. 9

    java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0 +

  10. 10

    java.util.regex.PatternSyntaxException: Unclosed character class near index 44

  11. 11

    Javascript regex to remove unmatched closing HTML tags?

  12. 12

    Java string split() Regex

  13. 13

    Java string split() Regex

  14. 14

    js split with regex will keep unmatched seperator

  15. 15

    java - using regex to split string

  16. 16

    Java regex split string not working

  17. 17

    Regex based string split in Java

  18. 18

    How to split a java string with a regex?

  19. 19

    java - using regex to split string

  20. 20

    Regex to find and fix unmatched xml closing tags in notepad++

  21. 21

    String split Operation based on characters in java

  22. 22

    How to extract the unmatched portion of a string using a regex

  23. 23

    Java Caching String.split Regex

  24. 24

    Java regex to split string with variable spaces and delimiter

  25. 25

    Java regex split string after number

  26. 26

    How to split this string in java need regex?

  27. 27

    Java String split with regex ignoring content in parenthesis

  28. 28

    How to split string by java regex with look behind?

  29. 29

    Java Regex to split a String with int, doubles

HotTag

Archive