我在一些 nemerle 代码中有以下方法:
private static getLinks(text : string) : array[string] {
def linkrx = Regex(@"<a\shref=['|\"](.*?)['|\"].*?>");
def m = linkrx.Matches(text);
mutable txmatches : array[string];
for (mutable i = 0; i < m.Count; ++i) {
txmatches[i] = m[i].Value;
}
txmatches
}
问题是编译器出于某种原因试图解析正则表达式语句中的括号并导致程序无法编译。如果我删除@,(我被告知放在那里)我在“\s”上得到一个无效的转义字符错误
下面是编译器输出:
NCrawler.n:23:21:23:22: ←[01;31merror←[0m: when parsing this `(' brace group
NCrawler.n:23:38:23:39: ←[01;31merror←[0m: unexpected closing bracket `]'
NCrawler.n:22:57:22:58: ←[01;31merror←[0m: when parsing this `{' brace group
NCrawler.n:23:38:23:39: ←[01;31merror←[0m: unexpected closing bracket `]'
NCrawler.n:8:1:8:2: ←[01;31merror←[0m: when parsing this `{' brace group
NCrawler.n:23:38:23:39: ←[01;31merror←[0m: unexpected closing bracket `]'
NCrawler.n:23:38:23:39: ←[01;31merror←[0m: unexpected closing bracket `]'
(第 23 行是上面带有正则表达式代码的行)
我该怎么办?