[問題] Regex
如題,先給String ss = "
<TR><TH scope="row" valign="top" align="left" width="10%" nowrap>Appl.
No.:
</TH><TD align="left" width="90%">
<b> 08/940,685</b></TD></TR>
<TR><TH scope="row" valign="top" align="left" width="10%">Filed:
</TH><TD align="left" width="90%">
<b>September 30, 1997</b></TD></TR>
</TABLE>
";
我希望得到的是"940,685",從"Appl. No"開始
程式碼如下:
str = "" + new Regex(@"Appl. No.:[^*]*?\/(.*)?(</b>)",
RegexOptions.IgnoreCase).Match(ss).Groups[1];
從測試網站 http://regexstorm.net/tester 來看應該是正確的。
不過用C#實際輸出:console.writeline(str);
會變成整個ss字串一起出來..,如果改成groups[2] 又能正常輸出</b>的結果出來
求解..
環境:visual studio 2017
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.231.168.220
※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1516592023.A.0B9.html
※ 編輯: alpho (36.231.168.220), 01/22/2018 11:34:27
→
01/22 12:39,
6年前
, 1F
01/22 12:39, 1F
推
01/23 09:53,
6年前
, 2F
01/23 09:53, 2F