From 56e026d12fcbc5830b1167d27a1be2c8fa638fef Mon Sep 17 00:00:00 2001
From: zyx <1029606625@qq.com>
Date: Thu, 20 Oct 2022 09:17:06 +0800
Subject: [PATCH] 2022/10/20 9:17
---
Week8/src/Exercise2.java | 4 ----
Week8/src/Exercise3.java | 13 +++++--------
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/Week8/src/Exercise2.java b/Week8/src/Exercise2.java
index a421222..01d4ea7 100644
--- a/Week8/src/Exercise2.java
+++ b/Week8/src/Exercise2.java
@@ -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 = "
欢迎访问武汉纺织大学主页\n" +
diff --git a/Week8/src/Exercise3.java b/Week8/src/Exercise3.java
index cee8e2e..56ead0e 100644
--- a/Week8/src/Exercise3.java
+++ b/Week8/src/Exercise3.java
@@ -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 = "";
+ String htmlStr = "" +
+ "" +
+ "";
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();
}
}
}