其他教程

其他教程

Products

当前位置:首页 > 其他教程 >

正则表达式截取字符串急急急急

GG网络技术分享 2025-03-18 16:15 3


问题描述:

@:2120100301@+@:2120100302@+@:2120100303@+@:2120100304@截取@:与@之间的数字串,再截取运算符号+

网友观点:

String regEx = \\\"(@:)(\\\\d{1,20})(@)\\\";

String url = \\\"@:2120100301@+@:2120100302@+@:2120100303@+@:2120100304@\\\";

Pattern p = Pattern.compile(regEx);

Matcher m = p.matcher(url);

long sum = 0;

while (m.find()) {

String number=m.group(2);

sum+=Integer.parseInt(number);

System.out.println(number);

}

System.out.println(sum);

[快速掌握正则表达式](http://blog.csdn.net/eyishion/article/details/51075984 \\\"快速掌握正则表达式\\\")

正则表达式从字符串中提取字符串怎么写?

C#

标签:

提交需求或反馈

Demand feedback