matcher.matches() 完全匹配 matcher.find() Pattern匹配

import java.util.regex.*
System.properties.putAll( ["http.proxyHost":"10.10.224.97", "http.proxyPort":"80","http.proxyUserName":"admin", "http.proxyPassword":"admin888"] )

def url="http://detail.tmall.com/item.htm?id=8039043384&"
url="http://www.baidu.com"
//html=url.toURL().text
//def matcher=( html=~ /<strong id="J_StrPrice"/ )
//println matcher
def html='''zzzzzz<strong id="J_StrPrice" >3399.00</strong>zzzz'''

html='''3333aaa'''

def matcher = html =~ /\d{4}/

println matcher.find()











println "==============================="



//println html
//def matcher = ( html =~ /<strong id="J_StrPrice" >([\s\S])*?<\/strong>/ )

println matcher.getCount()
println matcher.matches()
if (matcher.matches())
{
println matcher

}
else
{
println "xxxz"
}

你可能感兴趣的:(Pattern)