I have a problem with following script:
---
r = /^\\\$var\$/
if ('$var' ==~ r) println "ok"
---
groovy.lang.MissingPropertyException: No such property: var for class:
test_reg_err1
at test_reg_err1.run(test_reg_err1.gr:1)
It seems escaping dollar sign does not work inside slashy strings (
/^\$var\$/ gives same result).
However it does for r = "^\\\$jit\$" .
If to use dollar slashy string it refuses to compile at all:
---
r = $/^\\\$var\$/$
if ('$var' ==~ r) println "ok"
---
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test_reg_err1.gr: 3: unexpected char: 0xFFFF @ line 3, column 1.
(there are only 2 lines of code, and I'm using -Dfile.encoding=utf8)
Looks like a bug? Checked 1.8.2, 1.8.5
- Alexander
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
r = $/^\$$var$$/$
if ('$var' ==~ r) println "ok"
For slashy strings you would do something like:
r = /^\${'$'}var${'$'}/
but that is a bit more ugly hence the reason for dollar
slashy strings.
Cheers, Paul.