Re: [問題] re 用法

看板Python作者 (a9)時間17年前 (2008/06/28 00:11), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串7/8 (看更多)
※ 引述《plom (plom)》之銘言: : 請教各位我想找出字串中的英文字,用 re.compile(r'[\w]+') : 但是像 abc-def,abc -def, abc-def, 不想被拆開為 abc 和 def 兩個單字, 仍要為 abc-def : 請問該如何做呢? [\w]+\s?-\s?[\w]+|[\w]+ 我猜原PO的意思是想要將中間有-的視為同一個單字 測試字串如下 abc abc-def abc - def abc- def abc -def 因此先 match 具有-連接符號的單字 xxx-xxx 再 match 沒有連接符號的單字 抓出 abc abc-def abc - def abc- def abc -def -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 221.169.187.111
文章代碼(AID): #18PH4r-F (Python)
討論串 (同標題文章)
本文引述了以下文章的的內容:
2
3
17年前, 06/24
以下文章回應了本文
0
2
完整討論串 (本文為第 7 之 8 篇):
0
2
2
3
17年前, 06/24
文章代碼(AID): #18PH4r-F (Python)