我想突出显示字符串中与字符串的一部分匹配的模式。我已经确定了字符串中的模式并将它们存储在数组中。现在我希望它们在 word 文档中的文本中突出显示,以表明这些是匹配字符串部分的模式。
我已经使用 Apache POI 在 word 文档中编写了我的字符串,并创建了 word 2007 文档。
但我不知道如何在word文档中突出显示字符串中的模式。
我在后端使用了数据库,在其中放置了我的模式,然后在数组中使用了这些预排序的模式来查看它们是否出现在我的字符串中。
这是我的代码。
for(int j=0;j<numRows;j++)
{
Pattern p = Pattern.compile( strArray[j] );
m=p.matcher(str);
while(m.find())//finding pattern in the sequence
{
patArray[inpat]=m.group();// stored match pattern in another array
inpat++;
System.out.println(m.group());
}
}