Re: [問題] 一個簡單的問題~~
看板RegExp (正規表示式 Regular Expression)作者LPH66 (-858993460)時間14年前 (2010/07/25 17:28)推噓6(6推 0噓 0→)留言6則, 6人參與討論串2/2 (看更多)
※ 引述《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
推
07/26 13:15, , 1F
07/26 13:15, 1F
推
07/27 20:16, , 2F
07/27 20:16, 2F
推
07/27 22:31, , 3F
07/27 22:31, 3F
推
08/03 11:09, , 4F
08/03 11:09, 4F
推
08/04 03:55, , 5F
08/04 03:55, 5F
推
08/11 23:30, , 6F
08/11 23:30, 6F
討論串 (同標題文章)
RegExp 近期熱門文章
PTT數位生活區 即時熱門文章