Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java String doubt

 
elilvannan nagarajah
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 {}.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
test.substring(test.indexOf("{")+1, test.indexOf("}"))

might do the trick.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using JDK1.4 or later, take a look at regular expressions.
 
elilvannan nagarajah
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks "Ulf Dittmer" and "Ilja Preuss".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic