Java split on ^ (caret?) not working, is this a special character?

前端 未结 5 1656
醉酒成梦
醉酒成梦 2020-11-30 13:33

In Java, I am trying to split on the ^ character, but it is failing to recognize it. Escaping \\^ throws code error.

Is this a special char

5条回答
  •  心在旅途
    2020-11-30 14:08

    None of the above answers makes no sense. Here is the right explanation.

    1. As we all know, ^ doesn't need to be escaped in Java String.
    2. As ^ is special charectar in RegulalExpression , it expects you to pass in \^
    3. How do we make string \^ in java? Like this String splitstr = "\\^";

提交回复
热议问题