java - How get the some numbers from the string -


i have string "9x1x121: 1001, 1yxy2121: 2001, role: zzzzz" , need numbers input string.

string input = "9x1x121: 1001, 1yxy2121: 2001, role: zzzzz"; string[] part = input.split("(?<=\\d)(?=\\d)"); system.out.println(part[0]); system.out.println(part[1]); 

i need output below numbers only

1001 2001

you split on ',' split splitted string on ': ' , check if part[1] number or not (to avoid cases role).

string input = "9x1x121: 1001, 1yxy2121: 2001, role: zzzzz"; string[] allparts = input.split(", "); (string part : allparts) {     string[] parts = part.split(": ");     /* parts[1] need if it's number */     } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -