Groovy: How can I include backslashes inside a string without escaping?

Wow, another gotcha with putting Windows files paths in slashy strings. Nice catch. The gotcha I’ve encountered before was including a trailing backslash on the path, e.g. /C:\path\/, which results in an unexpected char: 0xFFFF error.

Anyways, for the sake of an answer, given that Windows paths are case insensitive, why not exploit it for once?

def s = /C:\DEV\USERNAME/

The \u unicode character escape sequence is case sensitive.

Leave a Comment

techhipbettruvabetnorabahisbahis forumueduedusedueduseduedusedusedueduedu