Groovy web console

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

Replacing $ in a string

Published 1 year 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