This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 41124
test.substring(test.indexOf("{")+1, test.indexOf("}"))

might do the trick.

Ping & DNS - my free Android networking tools app
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
Similar Threads
Reading mail content
java v6 regex question
Can any one please tell the reason for the String related question.. given here
Question on jar files and classpath.
can not send jsp param when using HttpServletRequestWrapper ?