posted 15 years ago
The "load it all into memory" was my approach. Here is the code, for what it is worth. It's not great but it works:
If your target string has a size that can be determined (i.e. no wildcards in the regex) then you could just read in the first block of characters of that size into some kind of buffer, compare, if no match found write the first char out, shuffle everything forward one char, read in next char, compare again. As soon as you get a match, write the whole replacement to the output, clear the buffer and read a full block in. Repeat until EOF.
As for the Scanner and endpoints: I think because they are delimiters, there is nothing before the first one nor after the last as far as the Scanner is concerned. But I'd need to read-up again on regex etc (I seem to recall there are a few rules around endpoints and null matches etc).