Groovy web console

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

Testing your regex

Published 5 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
String specialCharRegex = "[\\W|_]";
String term = /* put your test input here */

term = term.replaceAll(specialCharRegex, '\\\\$0')

term