• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use Delimter

 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to split a string using " ( " as a delimiter.

My code for that is :


but its throwing error as "Exception in thread "main" java.util.regex.PatternSyntaxException: Unmatched closing ')'
)"


How to mention a backet as a delimiter??

Thank you
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15219
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The argument that you pass to the split method is a regular expression, and ( has a special meaning in regular expressions. You need to escape it:
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper Young wrote:The argument that you pass to the split method is a regular expression, and ( has a special meaning in regular expressions. You need to escape it:



Thank You.

Suppose if i have more than one delimiter how can i split it at a time??

Is there any way for it or i have to split it sperately???
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15219
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neeba Rebbaca wrote:Suppose if i have more than one delimiter how can i split it at a time??

Write a regular expression that matches all the characters or character sequences that you want to be recognised as delimiters.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic