Regular expression that excludes characters before code 255

Dear masters! Is it possible to guarantee that only characters with codes between 0 and 255 will be accepted by the regular expression, but all with codes up to 256 not? Thank!

+3
source share
2 answers

Yes, you can represent hexadecimal ranges in regular expression:

boolean matches = string.matches("[\\x00-\\xFF]+");

This will match anything that contains at least one character in the range 0x00-0xFF.

+2
source

You can match [\x00-\xFF], i.e. a range of characters from 0 to 255.

0
source

Source: https://habr.com/ru/post/1738950/


All Articles