Groovy web console

subscribe to the feed Subscribe
to this
site

regex matcher is dumb

Published 2 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def str = """[image-frames-tests] --- results ---
[image-frames-tests] {
[image-frames-tests]     "stats": {
[image-frames-tests]         "total": 9,
[image-frames-tests]         "successes": 9,
[image-frames-tests]         "failures": 0,
[image-frames-tests]         "error_ids": []
[image-frames-tests]     },
[image-frames-tests]     "errors": {}
[image-frames-tests] }"""
def pattern = '"failures": 0'

if (str =~ pattern) { println "true" } else { println "false" }
if (str !=~ pattern)  { println "true" } else { println "false" }
if (!(str =~ pattern))  { println "true" } else { println "false" }