Java Regular Expression remove HTML Video Tag

Description

Java Regular Expression 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  .java 2s .  co  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