File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes java String doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java String doubt" Watch "java String doubt" New topic

java String doubt

elilvannan nagarajah

Joined: Apr 17, 2005
Posts: 8
How can i get content inside double brackets in a String in JAVA.
For Example String test="furious{ex1234}";
i want to get the "ex1234" from above string test.
any methods available to get the content beween {}.

SCJP 1.4<br />SCWCD 1.4 <br />SCBCD 1.3<br />SCEA (Part1)
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
test.substring(test.indexOf("{")+1, test.indexOf("}"))

might do the trick.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
If you are using JDK1.4 or later, take a look at regular expressions.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
elilvannan nagarajah

Joined: Apr 17, 2005
Posts: 8
Thanks "Ulf Dittmer" and "Ilja Preuss".
I agree. Here's the link:
subject: java String doubt
It's not a secret anymore!