How does one write a regular expression in java that will match all strings without the character code zero?
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
. Try changing it to:
Pattern.compile ("[^\0]+");
This should match one-or-more ( +
) characters that are not \\0
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.