我有一个字符串叫做s,
String s = "<NOUN>Sam</NOUN> , a student of the University of oxford , won the Ethugalpura International Rating Chess Tournament which concluded on Dec.22 at the Blue Olympiad Hotel";
我希望能从字符串中删除所有 <NOUN> 和 </NOUN> 标记。我使用了以下方法来移除标记:
s.replaceAll("[<NOUN>,</NOUN>]","");
是的,它会删除标签。但它也会从字符串中移除字母 'U' 和 'O',导致以下输出结果。
Sam , a student of the niversity of oxford , won the Ethugalpura International Rating Chess Tournament which concluded on Dec.22 at the Blue lympiad Hotel
请问如何正确地做这件事?
s.replaceAll("</?NOUN>","");
,因为问号匹配前面项的0或1个。 - Hubro