Split string at hyphen characters too

前端 未结 3 1783
故里飘歌
故里飘歌 2021-01-21 18:28

The line below splits my string on (.), (,), (:) and newline (\\n) characters.

String[] textPhrases = text.sp         


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-21 18:57

    This is regex. A hyphen has a special meaning inside a character class. You need to place the hyphen as the first or last item in the class:

    [-.,:\n]
    

提交回复
热议问题