下面的格罗维派指挥官说明了我的问题。
首先,这项工作(,如预期(0061/>t61/>)。
>>> print "a".matches(/u0061/)
true
Now let s say that we want to match
, using the Unicode escape u000A
. The following, using "pattern"
as a string, behaves as expected:
>>> print "
".matches("u000A");
Interpreter exception: com.google.lotrepls.shared.InterpreterException:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed,
Script1.groovy: 1: expecting anything but
; got it anyway
@ line 1, column 21. 1 error
这是因为,至少在 Java,统法协会的越狱程序早处理(JLS3.3),因此:
print "
".matches("u000A")
实际情况与:
print "
".matches("
")
固定装置是为了逃脱统法协会的密码,让列车的发动机进行如下操作:
>>> print "
".matches("\u000A")
true
现在这里的问题是部分:我们如何能够与格罗夫y <代码>/pattern/<合作。 syntax, 而不是使用脚石?
一些失败的尝试:
>>> print "
".matches(/u000A/)
Interpreter exception: com.google.lotrepls.shared.InterpreterException:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed,
Script1.groovy: 1: expecting EOF, found ( @ line 1, column 19.
1 error
>>> print "
".matches(/\u000A/)
false
>>> print "\u000A".matches(/\u000A/);
true