File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

java String doubt

elilvannan nagarajah
Greenhorn

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
Marshal

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

might do the trick.


Ping & DNS - my free Android networking tools app
Ilja Preuss
author
Sheriff

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
Greenhorn

Joined: Apr 17, 2005
Posts: 8
Thanks "Ulf Dittmer" and "Ilja Preuss".
 
jQuery in Action, 2nd edition
 
subject: java String doubt