Android kotlin and java split string String.split() escape character pit

Let's first talk about the special characters that need to be escaped in java. These characters are:

(    [     {    /    ^    -    $     ¦    }    ]    )    ?    *    +    . 

But these characters don't need to be escaped in kotlin.

1. Directly String.split() under the Android kotlin file

var arr = "aa|bb|cc".split("|")

You can get arr = {"aa", "bb", "cc"}

There is no need to escape special symbols.

2. Escaping is required under the Android java file, please see the attention points (escaping characters) of java splitting string String.split() method_java separator escaping_ErwinNakajima's blog-CSDN blog

Guess you like

Origin blog.csdn.net/NakajimaFN/article/details/130955803