java - logic for dynamic String using split function -


string x= "100,000"  string []y=x.split(",");  string z= y[0]+y[1] (give me expected result  100000) 

my question

if x dynamic, may sometime has "2 comas". "3 comas" (1,00,000 or 1,00,00,000 ) dynamic, can used separate comas , combine string.

you can replace ',' nothing instead of splitting string. in java this:

s.replaceall(",",""); 

if want split need loop iterates on string parts , puts new string.

example in java:

string x= "100,000" string []parts=x.split(","); string z= "";  for(string part : parts){     z+=part; } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -