Splitting a Java String by the pipe symbol using split(“|”)

前端 未结 7 1062
生来不讨喜
生来不讨喜 2020-11-21 23:32

The Java official documentation states:

The string \"boo:and:foo\", for example, yields the following results with these expressions Regex Result :

7条回答
  •  一个人的身影
    2020-11-22 00:11

    test.split("\\|",999);
    

    Specifing a limit or max will be accurate for examples like: "boo|||a" or "||boo|" or " |||"

    But test.split("\\|"); will return different length strings arrays for the same examples.

    use reference: link

提交回复
热议问题