Groovy web console

subscribe to the feed Subscribe
to this
site
Groovy regexp sucks (via #groovywebconsole)
tweet this snippet Tweet
this
script

Groovy regexp sucks

Published 2 months ago by Missing Python
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
r = "Build successfull"
print "Regex is " + r + "\n"
check_match(r)
check_match("ew\nBuild successfull somestring \na")
check_match("dfghdfgjxcvbrew\nBuild successful")
check_match("a34twseafd " + r + " zxcverafqwer")
check_match("a34twseafd" + r + "zxcverafqwer")

def check_match(s) {
    
    print "String:\n"  + s + "\n"
    if (s ==~ /(?s).*r*/) {
        print "Success! String matches " + r + "\n\n"
    } else {
        print "Failure! String does not match " + r + "\n\n"
    }
}