Splitting strings through regular expressions by punctuation and whitespace etc in java

后端 未结 4 1145
感动是毒
感动是毒 2020-12-01 12:28

I have this text file that I read into a Java application and then count the words in it line by line. Right now I am splitting the lines into words by a

St         


        
4条回答
  •  暖寄归人
    2020-12-01 12:44

    Well, seeing you want to count can't as two words , try

    split("\\b\\w+?\\b")
    

    http://www.regular-expressions.info/wordboundaries.html

提交回复
热议问题