I have implemented AsyncTask where the regular expression provided by the user is being used for matching huge html-code data. However, because some of the regular expressions contain a lot of quantifiers/backtracking, Matcher.find() goes infinite.
I have tried to use InterruptibleCharSequence provided here: How to terminate Matcher.find(), when its running too long?, but it seems that charAt is never get called, so never interrupted. My last guess is to create a new process just to run this regular matching procedure and then kill it when searching is cancelled. However, then I have a problem with sharing objects between Service and Activity, because of different processes.