I briefly looked at the source, and it seems that the file is read line by line using BufferedReader.readLine(). Then the regexp is checked against each of these lines. Clearly, setting the regexp attributes multiline or singleline will not allow to match against multiple lines of the file then. In contrast, the implementation of replaceregexp works as expected. I.e. it is able to match against multiple lines if configured appropriately.