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.
我尝试了许多排列,但它们似乎都不能很好地工作。我是否可以说 [\D^[\.]] 如果在 java matcher 中使用只会匹配那些非数字但不包括句号匹配?但是,它似乎不起作用...感谢您对我的问题的任何意见〜!
相反,确保字符串仅包含数字和句号并报告错误可能会更容易。(只是从另一个角度来看它......)
正则表达式非常简单:
/^[\d.]+$/
只需!在您的方法调用前添加一个匹配输入与模式的。
!
反转模式通常是获得所需内容的简单方法。