匹配RegEx中的第一行内容
Matching the first line of content in RegEx
我只想匹配 0 到 799 之间的数字,如果其中没有逗号。
0
我试过使用 这个正则表达式。 --> \b(0*(?:[0-9]?[0-9]?[0-9]?|100))\b
效果很好。
(如果数字在0和999之间)
Need help with changing my regex:
- I need it to work in JavaScript.
- I'd like to validate the number in the first row using regex after the $ (I only need
It,if It's between 0 and 799)
- If it has a comma in it then it should be ignored( like numbers 799+)
- 我不希望它接受其中带有 逗号 的数字,因为我当前的正则表达式认为它是有效的。
(或者至少 6,245 应该等于 6245 所以我的正则表达式可以忽略它。)
要重新表述您的问题,数字之前或之后不能有逗号:
(?<!,)\b[1-7]?\d?\d\b(?!,)
如果你不能使用向后看,例如,如果你使用 JavaScript,你将不得不消耗非逗号并捕获目标:
(^|[^,])(\b[1-7]?\d?\d\b(?!,))
号码在第1组
我只想匹配 0 到 799 之间的数字,如果其中没有逗号。
0
我试过使用 这个正则表达式。 --> \b(0*(?:[0-9]?[0-9]?[0-9]?|100))\b
效果很好。
(如果数字在0和999之间)
Need help with changing my regex:
- I need it to work in JavaScript.
- I'd like to validate the number in the first row using regex after the $ (I only need It,if It's between 0 and 799)
- If it has a comma in it then it should be ignored( like numbers 799+)
- 我不希望它接受其中带有 逗号 的数字,因为我当前的正则表达式认为它是有效的。 (或者至少 6,245 应该等于 6245 所以我的正则表达式可以忽略它。)
要重新表述您的问题,数字之前或之后不能有逗号:
(?<!,)\b[1-7]?\d?\d\b(?!,)
如果你不能使用向后看,例如,如果你使用 JavaScript,你将不得不消耗非逗号并捕获目标:
(^|[^,])(\b[1-7]?\d?\d\b(?!,))
号码在第1组