使用正则表达式我想匹配如下字符串:
我做了@"^3\.\d+[ ]."
但是我想不匹配"3"的字符串.接着是单一的1:
我试过@"^3\.[^1][ ]."但它不匹配像3.10这样的字符串
那么如何匹配除1号以外的任何数字?
先感谢您
@"^3\.(?!1\b)\d+ ."
Run Code Online (Sandbox Code Playgroud)
说明:
^ # Start of the string
3\. # Match 3.
(?! # Assert that it's impossible to match...
1 # the digit 1
\b # followed by a word boundary (i. e. assert that the number ends here)
) # End of lookahead assertion
\d+ # Then match any number.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3647 次 |
| 最近记录: |