<html>
<head>
<meta http-equiv=content-type content="text/html; charset=utf-8">
<title>测试</title>
</head>
<body>
<script>
var playMode = function(id) {
document.getElementById(id).Mode = '2';
}
</script>
<div>
<object id="654" codebase="PenBox.ocx"
classid="clsid:B230D908-78AA-4BDA-A61F-E0D3F" width="764"
height="500">
<param name="_Version" value="65536" />
<param name="_ExtentX" value="20214" />
<param name="_ExtentY" value="13229" />
<param name="LoadDataURL"
value="http://www.youerw.com /coursedown/2012/654/mengd/49921/xmlpath/mengd1338860138788.xml" />
<param name="UserName" value="" />
<param name="MarkColor" value="255" />
</object>
<br />
<button onclick="playMode('654')">播放</button>
</div>
</body>
</html>
只要取出:http://www.youerw.com /coursedown/2012/654/mengd/49921/xmlpath/mengd1338860138788.xml
String str = "你的字符串";
Java code
Matcher matcher = Pattern.compile("<param\\p{Space}+name\\p{Space}*=\\p{Space}*\"LoadDataURL\"\\p{Space}+value\\p{Space}*=\\p{Space}*\"(.*?)\"").matcher(str);
while(matcher.find())
System.out.println(matcher.group(1));
如果是解析本地html文件 ,可以这样
Java code
public static void main(String[] args)throws Exception {
File file = new File("C:\\Documents and Settings\\zhoufeng\\桌面\\aaa.html");
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String line = null;
StringBuilder sb = new StringBuilder();
while((line = br.readLine()) != null){
sb.append(line + "\r\n");
}
System.out.println(sb);
Matcher matcher = Pattern.compile("<param\\p{Space}+name\\p{Space}*=\\p{Space}*\"LoadDataURL\"\\p{Space}+value\\p{Space}*=\\p{Space}*\"(.*?)\"").matcher(sb.toString());
while(matcher.find())
System.out.println(matcher.group(1));
}
have a try
Java codeString s = ...; //LZ的字符串
Matcher m = Pattern.compile("(?is).*?<param name=\"LoadDataURL\" value=\"(.*?)\".*");
while (m.find()) {
System.out.println(m.group(1));
}