java, regular expression, need to escape backslash in regex

前端 未结 4 662
予麋鹿
予麋鹿 2020-12-01 21:08

With reference to below question - String.replaceAll single backslashes with double backslashes

I wrote a test program, and I found that the result is true in both

4条回答
  •  广开言路
    2020-12-01 21:50

    The first form \\t will be expanded to a tab char by the pattern class.

    The second form \t will be expanded to a tab char by Java before it builds a pattern.

    In the end, you get a tab char either way.

提交回复
热议问题