gpt4 book ai didi

regex - 范围 (2-16) 的正则表达式

转载 作者:行者123 更新时间:2023-12-03 02:02:25 28 4
gpt4 key购买 nike

我想匹配 2-16 之间的数字,范围为 1 位数到 2 位数。

正则表达式.info has examples对于 1 或 2 位数字范围,但不能跨越两个数字范围:

The regex [0-9] matches single-digit numbers 0 to 9. [1-9][0-9] matches double-digit numbers 10 to 99.

类似 ^[2-9][1-6]$ 匹配 21 甚至 96!任何帮助将不胜感激。

最佳答案

^([2-9]|1[0-6])$

将匹配 2 到 9(含)之间的单个数字,或者 1 后跟 0 到 6(含)之间的数字。

关于regex - 范围 (2-16) 的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3451389/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com