此正则表达式未找到任何匹配项.在其他语言中我运行它,效果很好.在像rubular.com这样的在线正则表达式测试人员中,它非常有用.
在java中,它不起作用.
有什么不同的java正则表达式,他们打破这样的事情?
为什么不起作用?此外,我怎么能在将来弄清楚他们为什么不匹配?
样本数据
<link>http://www.wunderground.com/US/MI/Milan.html</link>
<description><![CDATA[Temperature: 89.4°F | Humidity: 62% | Pressure: 29.65in (Steady) | Conditions: Clear | Wind Direction: NW | Wind Speed: 1.6mph<img src="http://server.as5000.com/AS5000/adserver/image?ID=WUND-00070&C=0" width="0" height="0" border="0"/>]]>
</description>
Run Code Online (Sandbox Code Playgroud)
和代码
protected void parseTemperature()
{
Pattern p = Pattern.compile("/Temperature: ([0-9.]+)°/");
Matcher m = p.matcher(this.xml);
if (m.find())
{
this.temperature = Double.valueOf(m.group(1));
}
}
Run Code Online (Sandbox Code Playgroud)