illegal string body character after dollar sign

Just use single quotes:

def x = 'anish$'

If this isn't possible, the only thing that's going to cause you problems is $, as that is the templating char used by GString (see the GString section on this page -- about half way down)

Obviously, the backslash char needs escaping as well, ie:

def x = 'anish\\'

You can use octal representation. the character $ represents 044 in octal, then:
def x = 'anish\044'

or
def x = 'anish\044'

For example, in Java i did use like this:
def x = 'anish\044'

If you wants knows others letters or symbols converters, click here :)

Tags:

Groovy