Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在健身中使用正则表达式时遇到问题。我想获得一个 10 位数字序列的正则表达式。我尝试了以下 -
=~/\d{10}/
和
=~/[0-9]{10}/
但这些都行不通。对于示例输入说“1234”,上面的正则表达式以绿色传递。
在fitnesse中测试10位数字序列的正则表达式是什么?
您的正则表达式匹配序列只有 10 位,但不是 4,您必须写\d{1,10}
\d{1,10}
尝试添加开始/结束锚点,例如
=~/^\d{10}$/
或者如果 10 位数字嵌入在其他文本中,则可能是单词锚:
=~/\b\d{10}\b/