If I have a piece of text around 3000 characters. I want search for strings with certain characteristics for example strings like [*]
.
That is, I want to get [a]
and [bc]
from
sjfhshdkfjhskdhfksdf[a]sfdsgfsdf[bc]
I know there is an algorithm called KMP that guarantee a linear time searching operation through a text, but here I don't have a fixed string to be found, maybe I have to use some regular expression at some place.
How can I do this better than O(n^2)? Is there any light libraries for this if I'm using java?