groovy - Why isn't this regex working? -
regex works fine here, script gets choked on underscores when run it. underscores should not need escaped... deal?
just trying grab leading/trailing $ , _:
def somestring1 = "__test" def somestring2 = "$test" def somestring3 = "test_" def somestring4 = "$test_" //... def matcher = somestring1 =~ /([\$_]*)(.+?)([\$_]*)/ using netbeans ide , coloring of regex indicates thinks underscores variables. same true if dollar signs escaped or not escaped.

the express $_ in regex back-reference entire input string. try changing regex this:
([_\$]*)(.+?)([_\$]*)
Comments
Post a Comment