Regex in java where text on which search is being done is dynamically changing : In java find()+start()+end() can be used for extracting regex pattern which occur more than one time using there functions on matcher object.

    Patter p = Patter.compile(regex);
    Matcher matcher = p.matcher(text);
    while(matcher.find()){
        // do something
    }

In my case text is changing with every find() in while loop so next time matcher.start() and matcher.end() gives wrong indices. I mean these indices are correct for old text but as text is changing it gives incorrect indices.
Im stuck here, pLease help. Thanks a lot in advance.
