我有一些nemerle代码如下方法:语法错误匹配链接的URL
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行是行与正则表达式代码就可以了)
我该怎么办?
只是为了记录在案,该功能被称为“逐字字符串文字“。 – CMS 2009-02-28 06:44:13