How to remove text between <script></script> tags
问题 I want to remove the content between <script></script> tags. I'm manually checking for the pattern and iterating using while loop. But, I'm getting StringOutOfBoundException at this line: String script = source.substring(startIndex,endIndex-startIndex); Below is the complete method: public static String getHtmlWithoutScript(String source) { String START_PATTERN = "<script>"; String END_PATTERN = " </script>"; while (source.contains(START_PATTERN)) { int startIndex=source.lastIndexOf(START