Groovy web console

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

regex

Published 4 months ago by Avi
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def name = "abc"
def re = /^${name}$/
def good = "abc" ==~ re
def bad1 = "tabc" ==~ re
def bad2 = "abct" ==~ re
def bad3 = "tabct" ==~ re
println "good should match. Matches? ${good}"
println "bad1 should NOT match. Matches? ${bad1}"
println "bad2 should NOT match. Matches? ${bad2}"
println "bad3 should NOT match. Matches? ${bad3}"