java开发实战经典(第二版)P368 11-6

xiaoxiao2021-03-01  25

11.6   

给定下面的HTML代码:

<font face ="Arial,Serif" size="+2"color="red">

要求对内容进行拆分,拆分之后的结果是:

face Arial,Serif

size +2

color red

package book; public class JiOu { public static void main(String args[]) { String str = "<font face=\"Arial,Serif\" size=\"+2\" color=\"red\">"; String s[] = str.split(" "); String str1 = s[1].replaceAll("\"|<", " "); String str2 = s[2].replaceAll("\"", " "); String str3 = s[3].replaceAll("\"|>", " "); String s1[] = str1.split("="); String s2[] = str2.split("="); String s3[] = str3.split("="); System.out.println(s1[0] + " " + s1[1]); System.out.println(s2[0] + " " + s2[1]); System.out.println(s3[0] + " " + s3[1]); } }

运行结果:

face Arial,Serif size +2 color red

 

转载请注明原文地址: https://www.6miu.com/read-4050102.html

最新回复(0)