regex for character code 0 in java

java, regex

Solution

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`.

Problem

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.

Original source