java - How to get the integer values from the String -


this question has answer here:

my string like

string body = "gh 1234 ring 5"; 

i want extract number 1234, ring , last 5 separate variables , want compare each of values..it like.. pass = 1234, cmnd = ring , duration = 5 this.. please me figure out how achieve this. im doing like

string body="gh 1234 ring"; string pass=bodypass = body.replaceall("[^0-9]", ""); 

to 1234 in it.but cant find how retrieve ring , 5.

do this

string body = "gh 1234 ring 5"; string[] splited = body.split("\\s+"); 

now result

splited[0] = gh splited[1] = 1234 splited[2] = ring splited[3] = 5 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -