我正在C#中進行一些OCR工作,並提取了需要處理的文本。現在我需要使用正則表達式解析一行。字符串上Unicode字符的正則表達式
string checkNum;
string routingNum;
string accountNum;
Regex regEx = new Regex(@"\u9288\d+\u9288");
Match match = regEx.Match(numbers);
if (match.Success)
checkNum = match.Value.Remove(0, 1).Remove(match.Value.Length - 1, 1);
regEx = new Regex(@"\u9286\d{9}\u9286");
match = regEx.Match(numbers);
if(match.Success)
routingNum = match.Value.Remove(0, 1).Remove(match.Value.Length - 1, 1);
regEx = new Regex(@"\d{10}\u9288");
match = regEx.Match(numbers);
if (match.Success)
accountNum = match.Value.Remove(match.Value.Length - 1, 1);
的問題是,字符串中包含了必要的Unicode字符當我做了.ToCharArray()
,檢查字符串的內容,但它似乎從來沒有當我解析找他們串識別Unicode字符。我認爲C#中的字符串默認是Unicode。
您應該接受此答案,以防止線程每隔幾個月自動重新啓動。並且使用'regex'標籤而不是像'regularexpressions'這樣的變體 - 這是一個正則表達式專家尋找的(儘管事實證明這畢竟不是真正的正則表達式問題)。 – 2010-05-15 09:57:58