What about the triple single quotes which are not GStrings?

def myString = '''
$HOME
'''

2015-05-03 18:07 GMT+02:00 Paolo Di Tommaso <[email protected]>:

> Well, the goal is exactly to avoid the need to escape the $ characters !
>
> On Sun, May 3, 2015 at 6:05 PM, Owen Rubel <[email protected]> wrote:
>
>> I believe you need you have it in quotes and escape with backlslash and
>> escape the backslash as well
>>
>> def myString = '\\$variable'
>>
>> might be three backslashes though
>>
>> Owen Rubel
>> 415-971-0976
>> [email protected]
>>
>> On Sun, May 3, 2015 at 9:01 AM, Paolo Di Tommaso <
>> [email protected]> wrote:
>>
>>> Hi,
>>>
>>> I would need to implement a string literal in which the dollar char is
>>> not interpreted as variable placeholder, indeed to use a custom character
>>> to interpolate variables.
>>>
>>> For example I would like define a string like this:
>>>
>>>
>>> def DONE = 'Task completed'
>>>
>>>
>>> def script = /%
>>>
>>> mv file_name $HOME
>>> echo %DONE
>>> /%
>>>
>>>
>>>
>>> In which the $HOME string is ignored while  %DONE is interpolated as a
>>> groovy variable.
>>>
>>> Is there any way to do that ?
>>>
>>>
>>> Cheers,
>>> Paolo
>>>
>>>
>>>
>>>
>>
>


-- 
Guillaume Laforge
Groovy Project Manager
Product Ninja & Advocate at Restlet <http://restlet.com>

Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>

Reply via email to