简体   繁体   English

如何从字符串中删除(字母和特殊)字符并存储到一个数组中?

[英]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. 我的字符串数据就像DV_APLCN: 563 ,DV_DHR_APLCN: 5632, PIC_NOTE: 6254 ...等等。

So I need to separate only digit( ie ,563,3632,6254)s and need to store in an array. 所以我只需要分开数字(即,563,3632,6254),并需要存储在数组中。

Help me on this.with sample code. 使用示例代码帮助我。 data is very huge and different StringNames. 数据非常庞大,并且StringNames不同。

Try using regex Regex Tutorial . 尝试使用regex Regex教程

And no one will provide you with java code. 而且没有人会为您提供Java代码。 You need to show some effort from your side. 您需要从身边努力。

First You need to understand Java regular expression Pattern and then consider using String.split() . 首先,您需要了解Java正则表达式Pattern ,然后考虑使用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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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