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

时间:2021-03-25 21:35:18

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( i.e ,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。

2 个解决方案

#1


0  

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]

#2


3  

Try using regex Regex Tutorial.

尝试使用正则表达式Regex教程。

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

并且没有人会为您提供Java代码。你需要向你展示一些努力。

#1


0  

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]

#2


3  

Try using regex Regex Tutorial.

尝试使用正则表达式Regex教程。

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

并且没有人会为您提供Java代码。你需要向你展示一些努力。