2

css ファイルがあり、Java で正規表現を使用してすべての余白プロパティ (左、右、下) およびパディング (左、右) プロパティを削除したいのですが、これを手伝ってください

これは私のcssです

.calibre {
        background-color: white;
        display: block;
        font-family: Times New Roman;
        font-size: 1em;
        margin-bottom: 0;
        margin-left: 20pt;
        margin-right: 20pt;
        margin-top: 0;
        padding-left: 0;
        padding-right: 0;
        text-align: justify
        }

出力は次のようになります

.calibre {
        background-color: white;
        display: block;
        font-family: Times New Roman;
        font-size: 1em;
        text-align: justify
        }
4

1 に答える 1

3

これは私のために働いた:

String str = ".calibre {"+
     "   background-color: white;"+
     "   display: block;"+
     "   font-family: Times New Roman;"+
     "   font-size: 1em;"+
     "   margin-bottom: 0;"+
     "   margin-left: 20pt;"+
     "   margin-right: 20pt;"+
     "   margin-top: 0;"+
     "   padding-left: 0;"+
     "   padding-right: 0;"+
     "   text-align: justify"+
     "   }";


     System.out.println(str.replaceAll("(margin|padding).+?;", ""));

それは印刷しました:

.calibre {   background-color: white;   display: block;   font-family: Times New Roman;   font-size: 1em;                     text-align: justify   }
于 2012-06-06T06:57:08.287 に答える