正则表达式int Array

hac*_*ker 0 java regex arrays

如果可以将字符串参数转换为int数组,则需要对其进行验证。

String pattern = "(\\d+[,])+";
String test = "18,32,5,8,10";

test2.matches(pattern2) //returns false as i requires , in the end
Run Code Online (Sandbox Code Playgroud)

有什么办法可以忽略最后一个','

hwn*_*wnd 5

使用组构造来指定数字后应跟(,数字)...

\\d+(?:,\\d+)+
Run Code Online (Sandbox Code Playgroud)