groovy regex test

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.matches()
if (matcher.find())
{
println matcher[0][1]
//println matcher.getCount()
}
else
{
println "xxxz"
}

原文地址:https://www.cnblogs.com/lexus/p/2568446.html