Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.5.6
-
Fix Version/s: 1.8-beta-1
-
Component/s: regular expressions
-
Labels:None
-
Number of attachments :
Description
Logically, $ character in the regexp string should be escaped by two backslashes, one for preventing GString property lookup, and another to escape regexp's special meaning of $. But it doesn't seem to work with Groovy 1.5.6:
groovy> println 'Hi, $aaa'.replaceAll(/
$aaa/, 'Sergey')
Exception thrown: groovy.lang.MissingPropertyException: No such property: aaa for class: Script5
groovy.lang.MissingPropertyException: No such property: aaa for class: Script5
at Script5.run(Script5:1)
Note that:
println 'Hi, $aaa'.replaceAll("\\\$aaa", 'Sergey')works, so it's something specific to the slash form of strings.
println 'Hi, $aaa'.replaceAll("\\\$aaa", 'Sergey')