tags:

views:

57

answers:

1

Is there someway of escaping characters in Groovy regexes? It would be nice to write a single backslash instead of 4.

+2  A: 

You shouldn't need four of them. Two should be enough. e.g. to match anything with a backslash in it.

def file = /C:\geo\file.txt/
assert file =~ /.*\\.*/
jitter
This code :`x = "\\geo\\file.txt";assert x =~ /\\/` says unexpected char :'\'.
Geo
Ceck updated answer. This should work
jitter