我有在冗长的字符串中查找单词的函数。
如果变量“v”包含之间的字符串,则该行匹配<vocab></vocab>
if(p.matches("\\W"+v+"\\W"))
我希望这一行应该匹配 v 是 \n 或 \t 或空格之间的完整单词,并且不包含在另一个单词中。
这是我的字符串:
<meta>
<vocab>called</vocab>
</meta>
<para>
called to-VP,Reid-NP,television cameras-NP
called to-VP,Reid-NP,one of-NP
one of-VP,Reid-NP,ornate rooms-NP
called to-VP,Reid-NP,Capitol-NP
called to-VP,Reid-NP,ceremony-NP
passed on-VP,last week-NP,spending bill-NP
passed on-VP,last week-NP,House-NP
passed on-VP,last week-NP,Senate-NP
officially complete-VP,ceremony-VP/NP,action-NP
called to-VP,television cameras-NP,one-NP
called in-VP,television cameras-NP,Capitol-NP
called for-VP,television cameras-NP,ceremony-NP
called-VP,Reid-NP,television cameras-NP
age-NP,last week-NP,event-num
</para>