Groovy web console

subscribe to the feed Subscribe
to this
site

Parse instanceId from html

Published 3 weeks ago by clifmo
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
import java.util.regex.Matcher
import java.util.regex.Pattern

def html= "<a href=\"#\" onclick=\"showChangeLoadingPoint('1283229','267202','39','BUF-LHX', 'True','', 'False')\">39</a>"

Pattern pattern = Pattern.compile(/\(\'\d{5,}\',/)  
Matcher matcher = pattern.matcher(html)
if (matcher.find()) {             
     System.out.println(matcher.group(0)[2..-3]);         
}