Reputation: 2415
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.
Upvotes: 6
Views: 3604
Reputation: 38436
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
.
Upvotes: 9