I was using a REGEX pattern in java (given below):
for the string:

It works fine. But when I tried using the below pattern:

for the string:str =

Sorry about the image upload. Looks like the character ‘[]’ in a00[] is encoded differently on the browser. Any ways to read that character in a different manner? The same character has a different representation in notepad++. I’m using RXTX and inputStream.read(readBuffer) to read the data. Is there any way I can update my encoding methods in java to overcome this?
https://i.stack.imgur.com/FydBg.jpg
i.imgur.com
P.S: Sorry about the image description – if it type it out i cant represent that character.
when i copy paste that character, it becomes an empty space.
The strange symbol (└) looks like how ASCII 3 is represented in some fonts.
In Regex,
\bmatches a word boundary. That is, between an alphanumeric and non-alphanumeric character. It works in the first case because there is a digit (“9”) before the matched substring, and an exclamation mark (“!”) right after it (which is a non-alphanumeric character).In the second case you changed the exclamation mark to a letter, so there is no longer a transition from alphanumeric to non-alphanumeric.
The solution is to extend the Regex so it also matches the symbol and digit:
I used
\\x03\\dto match the codes. The last part(?= )is a look-ahead. It checks if it matches, but does not consume it. This is so, so you do multiple matches in a row.A simpler alternative, would be to just split the string on “└”, and examine the pieces.