Understanding regex in Java: split(“\t”) vs split(“\\t”) - when do they both work, and when should they be used

后端 未结 2 487
一生所求
一生所求 2020-11-29 09:10

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

2条回答
  •  醉话见心
    2020-11-29 09:32

    \ 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

提交回复
热议问题