看板 C_Sharp 關於我們 聯絡資訊
Regex 中 有一個屬性是 RightToLeft。 想請問一下,假設我的字串為 string a = "The 2D matrix representing an image.Rotate the image by 90 degrees"; 如果我要擷取由右邊第8的字元擷取至,由右邊數來第11個字元。 也就是,我要取得 "90" 這個字串。 想請問可以透過Regex做到嗎?? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.239.129.20 ※ 文章網址: http://www.ptt.cc/bbs/C_Sharp/M.1405003982.A.8E6.html
CCWck:配合[a-zA-z0-9|\s]{8,8}$應該可以 07/10 23:19
CCWck:但如果你只是要抓這個degree 用substring或indexof就可以了 07/10 23:19
don750421:後來研究出來,其實不用RightToLeft也可以做到。 07/13 23:32
don750421:參考網路上的做法是使用group... 07/13 23:32
don750421:.*(?<aaa>.{2}).{6} 但是有辦法把group拿掉嗎? 07/13 23:33