Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression avoiding characters up to code 255

Tags:

java

regex

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

like image 977
Mark Avatar asked May 25 '26 00:05

Mark


1 Answers

Yes, you can represent hex ranges in regex:

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

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

like image 52
BalusC Avatar answered May 26 '26 13:05

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!