Hi,
I have to find and replace some words from the document using regex. I am adding the regex as a pattern in replace function and replacing it inside the IReplacing implementation. I am adding the code below,
Pattern pattern = Pattern.compile("(\\|[a-zA-Z]+\\s*(\\{[a-zA-Z0-9\\(\\[\\+\\,\\-\\/\\)\\=\\:\\.\\'\\’\\\\\\&\\s*\\]]*\\})*\\|)", Pattern.CASE_INSENSITIVE);
FindReplaceOptions findReplaceOptions = new FindReplaceOptions(FindReplaceDirection.BACKWARD);
findReplaceOptions.setReplacingCallback(findAndReplaceCallBack);
NodeCollection<Paragraph> paragraphList = asposeUtil.getParagraphNodes(inputstream, document);
if (paragraphList != null) {
for (Paragraph paragraph : paragraphList) {
Range paragraphRange = paragraph.getRange();
try {
paragraphRange.replace(pattern, Constants.EMPTY_STRING, findReplaceOptions);
} catch (Exception e) {
throw new CimplyfiveException("Exception occured during token replacement : ", e);
}
}
}
It finds and replaces all the matches except this one |agTbl{sl(S. No)[10]}|
. While testing in an online regex compiler, this pattern as well matching.
Please help me to figure out the issue
Thank you