[英]How do I match any number after comma using regex?
I'm using this expression capture all numbers. 我正在使用此表达式捕获所有数字。
var regex = /\,([-+]?(\d*[.])?\d*)/g;
But it still captures preceding comma. 但是它仍然捕获前面的逗号。
How do I get rid of it? 我如何摆脱它?
Capture variable and detect comment in groups 捕获变量并检测组中的注释
Validate start letters and valid characters for code validate 验证起始字母和有效字符以进行代码验证
But it still captures preceding comma.
但是它仍然捕获前面的逗号。
No, it matches the preceding comma, but it doesn't capture it: 不,它与前面的逗号匹配 ,但是没有捕获它:
var regex = /\\,([-+]?(\\d*[.])?\\d*)/g; var str = "testing,123"; var match = regex.exec(str); console.log("The match was : " + match[0]); // ",123" console.log("But the capture was: " + match[1]); // "123"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.