Groovy web console

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

AN202D2EMax60-Regex

Published 4 months ago by will with tags regex limit length validate
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
println "Backslash    : " + "\\asdnflkaj. -sdfa45545445454455F4545454F544545454854545454 " .matches('^[\\.A-Za-z0-9 -]{0,59}[\\.A-Za-z0-9 -]$')
println "Forwardslash : " + "//asdnflkaj. -sdfa45545445454455F4545454F544545454854545454 " .matches('^[\\.A-Za-z0-9 -]{0,59}[\\.A-Za-z0-9 -]$')
println "Wrong Length : " + "1234567891123456789212345678931234567894123456789512345678961".matches('^[\\.A-Za-z0-9 -]{0,59}[\\.A-Za-z0-9 -]$')
println "NewLine      : " + "asdnflkaj. -sdfa4554544545445\n.5F454454F544545454854545454 " .matches('^[\\.A-Za-z0-9 -]{0,59}[\\.A-Za-z0-9 -]$')
println "Tab          : " + "asdnflkaj. -sdfa4554544545445\t.54545454F544545454854545454 " .matches('^[\\.A-Za-z0-9 -]{0,59}[\\.A-Za-z0-9 -]$')
println "Should pass  : " + "  asdnflkaj. -sdfa4554544545445.5F4545454F54454545454545454 " .matches('^[\\.A-Za-z0-9 -]{0,59}[\\.A-Za-z0-9 -]$')