我有一些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