Re: [戰文!?] Regular Expression的中譯
※ [本文轉錄自 Linux 看板]
作者: zxvc (執著) 看板: Linux
標題: Re: [戰文!?] Regular Expression的中譯
時間: Fri Jan 15 08:47:51 2010
http://mitpress.mit.edu/books/FLAOH/cbnhtml/glossary-R.html
Regular Expression A definition for a class of strings that can be
recognized by a finite-state automaton. An example of a class of strings that
is regular would be legal mathematical expressions using only ``+'' and
digits. An example that is not regular is the same legal mathematical
expressions as before, but with properly nested parentheses.
Ex1:
1+2+3
1+2
+1+2
...
Python RegExp:
import re
print re.match("\+?\d?[\+\d]*", "1+2+3").group(0)
Ex2:
(1+2)
((1)+2)
(((1))+2)
(1+(2))
(1+((2)+(3)))
...
請高手找出剛好match它們的RegExp!?
所以簡單的說regular不是指什麼正不正統,
而是指你能不能找到一個pattern match一組字串。
沒有"規律"的字串組,是找不到對應的pattern!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.71.93
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.71.93
→
01/15 10:40, , 1F
01/15 10:40, 1F
→
01/15 10:41, , 2F
01/15 10:41, 2F
→
01/15 10:42, , 3F
01/15 10:42, 3F
→
01/15 10:43, , 4F
01/15 10:43, 4F
→
01/15 10:44, , 5F
01/15 10:44, 5F
→
01/15 10:44, , 6F
01/15 10:44, 6F
→
01/15 11:14, , 7F
01/15 11:14, 7F
→
01/15 11:15, , 8F
01/15 11:15, 8F
→
01/15 11:15, , 9F
01/15 11:15, 9F
→
01/15 11:17, , 10F
01/15 11:17, 10F
→
01/15 11:17, , 11F
01/15 11:17, 11F
→
01/15 16:06, , 12F
01/15 16:06, 12F
→
01/15 16:06, , 13F
01/15 16:06, 13F
→
01/15 16:11, , 14F
01/15 16:11, 14F
→
01/15 16:12, , 15F
01/15 16:12, 15F
→
01/15 16:14, , 16F
01/15 16:14, 16F
→
01/15 16:27, , 17F
01/15 16:27, 17F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 4 之 6 篇):
RegExp 近期熱門文章
PTT數位生活區 即時熱門文章