[英]regex for character code 0 in java
How does one write a regular expression in java that will match all strings without the character code zero? 如何在java中编写一个正则表达式,它将匹配所有字符串而不是字符代码为零?
I've tried: 我试过了:
Pattern.compile ("[^\0]");
and 和
Pattern.compile ("[^\u0000]");
Thanks. 谢谢。
Your first regex is almost right, but it only matches a single character that is not \\0
. 你的第一个正则表达式几乎是正确的,但它只匹配一个不是
\\0
的单个字符。 Try changing it to: 尝试将其更改为:
Pattern.compile ("[^\0]+");
This should match one-or-more ( +
) characters that are not \\0
. 这应匹配不是
\\0
一个或多个( +
)字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.