Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing (x,y,z)

Status
Not open for further replies.

BTCMan

Programmer
Jun 17, 2005
21
BR
Hi people,

I need to extract some data from the pattern pattern:
(xxx,yyy,zzzz)

The output should be handled like this:
var1 = xxx;
var2 = yyy;
var3 = zzz;

Also, the digits may vary like: (xxx) OR (xxx,yyy)

I want to avoid using String split method or to remove the "(" and the ")" delimiters from the original string. All I really want is to retrieve the values I need from the entire string. Thanks in advance!
 
Why would you want to avoid the obvious solution?

Cheers,
Dian
 
Ok with the split method but before call it we need to remove undesired "(" and ")". I would like to see a single regular expression that retrieves the desired data.

Thanx
 
String[] parts = myString.replaceAll("()", "").split(",");

or something like that ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
thanx! actually I did:

String[] parts = myString.replaceAll("\\(\\)", "").split(",");

cheers

btcman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top