Java split is eating my characters.

Posted by Fenris_uy on Stack Overflow See other posts from Stack Overflow or by Fenris_uy
Published on 2010-05-12T14:51:52Z Indexed on 2010/05/12 14:54 UTC
Read the original article Hit count: 157

Filed under:
|
|
|

Hi, I have a string like this String str = "la$le\$li$lo".

I want to split it to get the following output "la","le\$li","lo". The \$ is a $ escaped so it should be left in the output.

But when I do str.split("[^\\\\]\\$") y get "l","le\$l","lo".

From what I get my regex is matching a$ and i$ and removing then. Any idea of how to get my characters back?

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about split