匹配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+)

要重新表述您的问题,数字之前或之后不能有逗号:

(?<!,)\b[1-7]?\d?\d\b(?!,)

Try it online.

如果你不能使用向后看,例如,如果你使用 JavaScript,你将不得不消耗非逗号并捕获目标:

(^|[^,])(\b[1-7]?\d?\d\b(?!,))

号码在第1组

Try it online.