본문 바로가기

tag to another tag for java

java by 낼스 2019. 9. 23.


public class Test {

    public static String changeTag(String v, String a,String b) {

    v = v.replaceAll("(?i)(<\\s*\\/?\\s*)" + a + "(\\s*([^>]*)?\\s*>)", "$1" + b + "$2");

    return v;

    }

    

public static void main(String[] args) {

String v = "<Script/></script><img src/><Script/></script><Script/></script><Script/></SCRIPT>";

System.out.println("step0 : " + v);

v = changeTag(v,"script","s.c.r.i.p.t");

System.out.println("step1 : " + v);

v = changeTag(v,"img","i.m.g");

System.out.println("step2 : " + v);

}

}


댓글