Java Regex Matcher remove HTML video tag

Description

Java Regex Matcher remove HTML video tag


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] argv) throws Exception {
        String html = "<object id=''><param name=\"src\" value=\"asdf\" asdf>asdf</object>";
        System.out.println(RemoveVideoTag(html));
    }//from   w  ww . j a  v a  2s  .  c  o  m

    static final Pattern patternVideo = Pattern
            .compile("<object(.+?)>(.*?)<param name=\"src\" value=\"(.+?)\"(.+?)>(.+?)</object>");

    public static String RemoveVideoTag(String html) {
        Matcher m = patternVideo.matcher(html);
        while (m.find()) {
            html = m.replaceAll("");
        }
        return html;
    }
}



PreviousNext

Related