2022/10/20 9:17
This commit is contained in:
parent
8376def1d7
commit
56e026d12f
@ -3,10 +3,6 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author : 张宇轩
|
||||
* @createTime : 2022/10/20 - 8:28
|
||||
*/
|
||||
public class Exercise2 {
|
||||
public static void main(String[] args) {
|
||||
String htmlStr = "<html><head><title>欢迎访问武汉纺织大学主页</title></head>\n" +
|
||||
|
@ -1,18 +1,14 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author : 张宇轩
|
||||
* @createTime : 2022/10/20 - 8:47
|
||||
*/
|
||||
public class Exercise3 {
|
||||
public static void main(String[] args) {
|
||||
String htmlStr = "<font face=\"Arial Serif\" size=\"10px\" color=\"red\" />";
|
||||
String htmlStr = "<font face=\"Arial Serif\" size=\"10px\" color=\"red\" />" +
|
||||
"<font face=\"Arial Serif\" color=\"red\" />" +
|
||||
"<font size=\"10px\" color=\"red\" />";
|
||||
Pattern p1 = Pattern.compile("<\\s*font\\s*([^>]*)\\s*>",Pattern.CASE_INSENSITIVE);
|
||||
Matcher m1 = p1.matcher(htmlStr);
|
||||
if(m1.find()) {
|
||||
while (m1.find()) {
|
||||
String fontStr = m1.group();
|
||||
Pattern p2 = Pattern.compile("([a-z]+)\\s*=\\s*\"([^\"]+)\"",Pattern.CASE_INSENSITIVE);
|
||||
Matcher m2 = p2.matcher(fontStr);
|
||||
@ -22,6 +18,7 @@ public class Exercise3 {
|
||||
eachAttribute = eachAttribute.replaceAll("\"","");
|
||||
System.out.println(eachAttribute);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user