看板 RegExp 關於我們 聯絡資訊
※ 引述《godisempty ()》之銘言: : 我想判斷一簡單的問題 但真的是re用時方恨不會 : 就是想判斷地址的幾樓 : 12樓 , 十二樓 需要抓出來 : 我想到規則就是 : "樓"的前面是英數的數字或是國字的數字 : 就是了 : 有高手可以提供一下解法嗎?? 還是用回的好了 如果你的中文是 unicode 那麼事情比較簡單 ([0-9]+|[一二三四五六七八九十百千]+)樓 如果中文是 Big5 的話 因為一個中文字其實是兩個字 所以得要 ([0-9]+|((一)|(二)|(三)|(功|)|(五)|(六)|(七)|(八)|(九)|(十)|(百)|(千))+)樓 之所以"四"要寫成"功|"是因為"四"的後半字是"|" 所以那個"|"要寫成"\|" 而"\"和"四"的前半字就合成了"功" -- "四"這個字也是"類許功蓋問題字"...只是它的後半不是 \ 是 | 而已 -- 'You've sort of made up for it tonight,' said Harry. 'Getting the sword. Finishing the Horcrux. Saving my life.' 'That makes me sound a lot cooler then I was,' Ron mumbled. 'Stuff like that always sounds cooler then it really was,' said Harry. 'I've been trying to tell you that for years.' -- Harry Potter and the Deathly Hollows, P.308 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.28.92
rainstraw:推, 沒處理過大概也猜不出要這樣.. 07/26 13:15
godisempty:讚.好清楚 07/27 20:16
aitjcize:推~ 07/27 22:31
seoker:推! 08/03 11:09
Pash77:推 08/04 03:55
nio127:厲害~ 08/11 23:30