S
sanjay010
I have a list of key words. It has around 1000 key word now but can
grow to 5000 keywords.
My web application displays lot of texts which are stored in the
database. My requirement is to scan each text for the occurance of any
of the above keywords. If any keyword is present I have to replace that
with some custom values, before showing it to the user.
I was thinking of using using regular expression for replacing the
keyword in the text using matcher.replaceAll method as follows:
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
String output = matcher.replaceAll(replacementStr);
But My pattern string will have around 5000 keywords with the 'OR'
Logical Operator like- keyword1| keyword2 I keyword3 | ..........
Will such a big pattern string adversly affect the performance? What
can I do to speed up the performance?(Since my keyword list is not
static i would prefer to do the replacement just before showing the
text to the user)
Any suggestions are most welcome.
grow to 5000 keywords.
My web application displays lot of texts which are stored in the
database. My requirement is to scan each text for the occurance of any
of the above keywords. If any keyword is present I have to replace that
with some custom values, before showing it to the user.
I was thinking of using using regular expression for replacing the
keyword in the text using matcher.replaceAll method as follows:
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
String output = matcher.replaceAll(replacementStr);
But My pattern string will have around 5000 keywords with the 'OR'
Logical Operator like- keyword1| keyword2 I keyword3 | ..........
Will such a big pattern string adversly affect the performance? What
can I do to speed up the performance?(Since my keyword list is not
static i would prefer to do the replacement just before showing the
text to the user)
Any suggestions are most welcome.