我有
String text2 = "Samaras did something by Papandreou's government.";
当我使用
时String[] w2 = text2.split("\\s+");
它需要" Papandreou"作为一个整体的词(正如它应该做的那样)。但是,我怎么能避免这个词之后的's
?
答案 0 :(得分:0)
text2.split("(\\'s)?\\s+");
This regular expression splits the 's as optional, so it means either "Split 's follow with spaces" or "Split only spaces".