I am writing a java program that parses some shell code and I want to remove the content inside echo statements. For the beginning, I want to take the whole echo command. My actual pattern looks like this:
Pattern pat = Pattern.compile("echo[\\t ]+\".*?\"");
This will match echo + at least one space or tab + double quotes + the smallest number of characters (I used the reluctant quantifier) + double quotes.
The problem is when I have an echo like this:
echo "This will not \" work";
My pattern will match only until backslash. What could I do fix this?