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.
我想要一个 Java 正则表达式来匹配除 B 或 S 之外的一个或多个非数字。目前我有这个:
\\D[^BS]+
但是这不起作用:/
帮助将不胜感激
您需要字符类中的数字:
[^\\dBS]+
或者,用锚
^[^\\dBS]+$
确保整个字符串匹配(但在 Java 中,该.matches()方法会为您处理)。
.matches()