Is there a way to escape characters in Groovy regexes?

Are there any escaped characters in Groovy regexes? It would be nice to write a single backslash instead of 4.

+2


source to share


1 answer


You don't need four of them. Two should be enough. for example to match anything with a backslash.



def file = /C:\geo\file.txt/
assert file =~ /.*\\.*/

      

+2


source







All Articles