Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Regex replacement for negative bytes in string

Tags:

java

regex

I'm getting a date from a web (html): " abril   2013  Viernes 19"

I've tried all normal regex with no success.

Finally I discovered the string bytes (str.getBytes()), and this are the values:

[-96, 97, 98, 114, 105, 108, -96, -96, -96, 50, 48, 49, 51, -96, -96, 86, 105, 101, 114, 110, 101, 115, -96, 49, 57]

What are this -96?

how to replace 1 or more -96 or whatever empty space is by 1 space?

like image 318
surfealokesea Avatar asked Dec 03 '25 16:12

surfealokesea


1 Answers

The byte -96 (A0 in hexadecimal, or 160 as an unsigned byte), is the non-breaking space in the ISO-8859-1 character encoding, which is probably the encoding you used to transform the string to bytes.

like image 190
JB Nizet Avatar answered Dec 06 '25 07:12

JB Nizet