Uncategorized

Pass Enum values by reference in Java

Posted on

Title might be little misleading since in java we pass always by value, but we can mimic passing by reference. /** * This class allows us to pass values by reference ranter than value. * Not directly as java just passes reference of the object by value but indirecly * @author Greg * * @param […]

Uncategorized

Regex to remove DOCTYPE prolog

Posted on

While using HTML Tidy I needed to remove the DOCTYPE prolog to prevent ‘org.xml.sax.SAXParseException: Already seen doctype.’ exception. Regex is quite simple, only catch is that we need to make sure we include the \n\r in our selecton and make it not greedy. convertedData = convertedData.replaceAll("<!DOCTYPE((.|\n|\r)*?)\">", ""); convertedData = convertedData.replaceAll("<!DOCTYPE((.|\n|\r)*?)\">", ""); This will consume multiline […]