Click here to load reader

정규 표현식

Embed Size (px)

DESCRIPTION

정규 표현식. Regular Expression 2011-03-26 봄싹 스터디 http://www.springsprout.org 발표자 : 강희석. 1 장 정규 표현식 소개 (1). 책 소개. http://www.yes24.com ☞ 표현식으로 검색 책 본문은 103 페이지 . 나머지는 부록 (60 페이지 ) 펄은 정규식 언어의 할아버지 격인 랭귀지. 1 장 정규 표현식 소개 (2). 정규 표현식을 시험해 볼 수 있는 툴. - PowerPoint PPT Presentation

Citation preview

Regular Expression

2011-03-26 http://www.springsprout.org : 1 (1)http://www.yes24.com 103 . (60)

.

1 (2)http://www.forta.com/books/0672325667/ Appendix C: The Regular Expression Tester JavaScript, JSP (p157)

EditPad Pro http://www.editpadpro.com/download.html

http://weitz.de/files/regex-coach.exe

2 (1) escape()

(\) . ) \. \\ \? \* \+ \^ \$

(\) .) \n \t \r 3 (1). | [] [^] - ([A-Z] )\ [Tip] (.) (newline) .

[\d\D] . . . .(alternation)

'or' (|) . .

/fred( |\t)+barney/ - . .

/fred( +|\t+)barney/ - fred barney . .

/fred (and|or) barney/ - fred and barney fred or barney (character class)

. .3 (2)3 (3)(-)

([]) . (-) (-) . (-) (\) .(^)

([]) .

([]) .4 (1) [\b]\f (form feed)\n\r \t\v \d ([0-9] .\D ([^0-9] )4 (2) \w ([a-zA-Z0-9_] ) .\W, ([^a-zA-Z0-9_] \s ([\f\n\r\t\v] )\S ([^\f\n\r\t\v] )\x 16 \0 8 4 (3)(POSIX) [:alnum:] ([a-zA-Z0-9] )[:alpha:] ([a-zA-Z] )[:blank:](space) ([\t ] )[:cntrl:] ( 0 31, 127)[:digit:] ([0-9] )[:graph:][:print:] (space) [:lower:] ([a-z] )[:print:] [:punct:][:alnum:] [:cntrl:] [:space:] ([\f\n\r\t\v ] )[:upper:] ([A-Z] )[:xdigit:] 16 ([a-fA-F0-9] )POSIX : Portable Operating System Interface. OS API , IEEE . http://ko.wikipedia.org/wiki/POSIX105 (1)(Quantifier)* *? * + +? + ? {n} n {m,n} m n {n,} n {n,}? {n,}5 (2)(greedy) (lazy) **?++?{n,}{n,}?[]This offer is not available to customersliving in AK and HI.[] .[]This offer is not available to customersliving in AK and HI.[ ] .* , .5 (3)[]This offer is not available to customersliving in AK and HI.[ ] .*?6 (1)^ \A $ \Z \ \b \B\b '' . .6 (2) (^) ($), (^) ($) . /^fred/ fred manfred mann . /rock$/ rock knute rockne ./^\s*$/ - 6 (3) . \b . /\bfred\b/ fred frederick alfred, manfred mann . ' (match whole words only') . . , \w . \b \w .\B - . \B \b . /\bsearch\B/ searches searching, searched search researching .7 (1)[] HTML 2 []Hello, my name is BenForta, and I am the author of books on SQL, ColdFusion, WAP,windows2000, and other subjects.[ ] {2,}[] . ??? [] IP []Pinging hog.forta.com [12.159.46.200]with 32 bytes of data:Wrong IP address: 31.299.46.200[ ] \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}[]Pinging hog.forta.com [12.159.46.200]with 32 bytes of data:Wrong IP address: 31.299.46.2007 (2)[ 2] (\d{1,3}\.){3}\d{1,3}? IP ? [IP ] 1 2 0 4 25 0 5 7 (3)[] IP [ ] (((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))[]Pinging hog.forta.com [12.159.46.200]with 32 bytes of data:Wrong IP address: 31.299.46.200[]ID:042SEX: MDOB: 1967-08-17Status: Active7 (4)[] 1900 2000 4 [ ] 19|20\d{2}[]ID:042SEX: MDOB: 1967-08-17Status: Active .[]This is a block of of text,serveral words here are arerepeated, and and they should not be.8 (1)[] 2 .[ ] [ ]+(\w+)[ ]+\1[]This is a block of of text,serveral words here are arerepeated, and and they should not be. 21[]Welcome to my HomepageContent is divided into two sections:
Coldfusion[] HTML .[ ] .*?[]Welcome to my HomepageContent is divided into two sections:
Coldfusion8 (2)9 (1) , ., .NET, PHP, . .(lookahead) . , . ?= (=) . - 9 (p85)239 (2). (consume) '.(consume)' . ' (not consume)' .[] URL , URL .[]http://www.forta.com/https://mail.forta.com/ftp://ftp.forta.com/[ ] .+(?=:)[]http://www.forta.com/https://mail.forta.com/ftp://ftp.forta.com/ ? .+(:)9 (3) - , ?= . , (consume) . ?= . (lookbehind) . . ?9 (11)[] .[]I paid $30 for 100 apples,50 oranges, and 60 pears.I saved $5 on this order.[ ] (?9 (12)[] .[ ] \b(?[]I paid $30 for 100 apples,50 oranges, and 60 pears.I saved $5 on this order.\b ?9 (13)[] , $30 0 . ? 0 ($) . .[ ] (?[]I paid $30 for 100 apples,50 oranges, and 60 pears.I saved $5 on this order. , . , ., . (?=) (?!) . (?9 (14)[ ]10 (1) , . ?(123)456-7890 123-456-7890 .1234567890, (123)-456-7890, (123-456-7890 , . ?10 (p97)3710 (2)[]123-456-7890(123)456-7890(123)-456-7890(123-456-78901234567890123 456 7890[ ] \(?\d{3}\)?-?\d{3}-\d{4}[]123-456-7890(123)456-7890(123)-456-7890(123-456-78901234567890123 456 7890( ) escape . ...[] \(? . (() .\d{3} , \)? . -? , \d{3}-\d{4} . . , . ()) (-) , .10 (3)\)?-? [\)-]? , ()) (-) , . (() ()) . , (-) , .10 (4) (?(backreference)true) , , .(?(backreference)true|false) else . . ( ) .[] .[ ] JDK 1.5, JDK 1.6, JavaScript(IE8,IE9,Chrome,FireFox) '' .[ ] (\()?\d{3}(?(1)\)|-)\d{3}-\d{4}[]123-456-7890(123)456-7890(123)-456-7890(123-456-78901234567890123 456 7890[] (123-456-7890 . 10 (5) ?10 (6)[ ] . (?)[ ] (\(\d{3}\)|(^|(?10 (18)[] .12345 ZIP 12345-6789 ZIP+4 . .[ ] \d{5}(-\d{4})?10 (19)[]111112222233333-44444-4444 ?[]111112222233333-44444-4444 .10 (20)[ ] \d{5}(?(?=-)-\d{4})[]111112222233333-44444-4444[Tip] .[ ](\d{5}-\d{4}\b|\d{5}(\s|$))10 (21)[Tip] , . . .5710 (22)[ ] . ( ) . . (1)[] . , . 0 , 728 .( ). , \d{3}-\d{2}-\d{4} . ?[] p12859 (2)[] John Smith: 123-45-6789000-00-0000000-00-0009727-00-0101728-11-1111738-00-0000729-00-0000888-88-8888726-11-1111[] p12860[]000-00-000 0 1 9 .000-00-000 0 7 , 7 ( ?