There are two errors in your [s+,'/]
regex:
The +
plus should be outside the [ ]
character class.
Reason: Without the +
, text "Sing, sing"
would have 2 separators, a comma and a space, with an empty token between them, and you're counting that empty token.
The '
apostrophe should not be there.
Reason: With the '
, text Don't
would be 2 words, not 1.
So the regex should be: [s,/]+
Changing nothing but the split call to split("[\s,/]+")
, the result becomes:
No of words : 51
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…