Groovy web console

subscribe to the feed Subscribe
to this
site
Replacing $ in a string (via #groovywebconsole)
tweet this snippet Tweet
this
script

Replacing $ in a string

Published 6 months ago by Nupur Ghatnekar with tags replaceAll Regex groovy
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def test ='''$werwer'''

println "test :: " +test 

def replace = test.replaceAll('\\$','___TEST___');

println "replace :: " +replace 

replace = replace.replaceAll('___TEST___','\\$');

println "replace :: " +replace