// extract number with which line begins def m = "1234 abc" =~ /^(\d+)/ println m[0][1]