I have recently figured out that I haven\'t been using regex properly in my code. Given the example of a tab delimited string str
, I have been using str.s
\
is consider to be escape char in java, so to get correct regex you need to escape \
with \
and t to indicate tab.
This tutorial will help more
When using "\t"
, the escape sequence \t
is replaced by Java with the character U+0009. When using "\\t"
, the escape sequence \\
in \\t
is replaced by Java with \
, resulting in \t
that is then interpreted by the regular expression parser as the character U+0009.
So both notations will be interpreted correctly. It’s just the question when it is replaced with the corresponding character.