简体   繁体   中英

How to Remove (alphabet & Special )characters from a String and store to one array?

my String Data is like DV_APLCN: 563 ,DV_DHR_APLCN: 5632, PIC_NOTE: 6254 ...etc.

So I need to separate only digit( ie ,563,3632,6254)s and need to store in an array.

Help me on this.with sample code. data is very huge and different StringNames.

Try using regex Regex Tutorial .

And no one will provide you with java code. You need to show some effort from your side.

First You need to understand Java regular expression Pattern and then consider using String.split() .

String str = "DV_APLCN: 563 ,DV_DHR_APLCN: 5632, PIC_NOTE: 6254";
System.out.println(Arrays.toString(str.split("\\D+")));

Output

[, 563, 5632, 6254]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM