加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式 – 如何匹配小于或等于100的数字?

发布时间:2020-12-14 06:28:16 所属栏目:百科 来源:网络整理
导读:嗨,我想匹配小于或等于100的数字,它可以是0-100之内的任何值,但正则表达式不应匹配大于100的数字,如120 130,150,999等. 尝试这个 b(0*(?:[1-9][0-9]?|100))b 说明 "b # Assert position at a word boundary( # Match the regular expression below and ca
嗨,我想匹配小于或等于100的数字,它可以是0-100之内的任何值,但正则表达式不应匹配大于100的数字,如120 130,150,999等.
尝试这个
b(0*(?:[1-9][0-9]?|100))b

说明

"
b                # Assert position at a word boundary
(                 # Match the regular expression below and capture its match into backreference number 1
   0              # Match the character “0” literally
      *           # Between zero and unlimited times,as many times as possible,giving back as needed (greedy)
   (?:            # Match the regular expression below
                  # Match either the regular expression below (attempting the next alternative only if this one fails)
         [1-9]    # Match a single character in the range between “1” and “9”
         [0-9]    # Match a single character in the range between “0” and “9”
            ?     # Between zero and one times,giving back as needed (greedy)
      |           # Or match regular expression number 2 below (the entire group fails if this one fails to match)
         100      # Match the characters “100” literally
   )
)
b                # Assert position at a word boundary
"

访问here以备将来出现问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读