File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to use Delimter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to use Delimter" Watch "How to use Delimter" New topic
Author

How to use Delimter

Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
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

Joined: Aug 16, 2005
Posts: 14278
    
  21

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:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Neeba Rebbaca
Ranch Hand

Joined: Oct 21, 2008
Posts: 159
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

Joined: Aug 16, 2005
Posts: 14278
    
  21

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to use Delimter