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.

enter image description here

the express $_ in regex back-reference entire input string. try changing regex this:

([_\$]*)(.+?)([_\$]*) 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -