home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: Mailbox/MIME Entity
(archive/mbox).
You can browse this item here: Regular_Expressions_3.txt
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 20 63 73 2e | 76 75 2e 6e 6c 21 73 75 |From cs.|vu.nl!su|
|00000010| 6e 34 6e 6c 21 45 55 2e | 6e 65 74 21 65 6e 65 77 |n4nl!EU.|net!enew|
|00000020| 73 2e 73 67 69 2e 63 6f | 6d 21 64 65 63 77 72 6c |s.sgi.co|m!decwrl|
|00000030| 21 70 61 67 65 73 61 74 | 2e 6e 65 74 21 6e 65 77 |!pagesat|.net!new|
|00000040| 73 2e 69 6e 63 6f 6e 6e | 65 63 74 2e 63 6f 6d 21 |s.inconn|ect.com!|
|00000050| 6e 65 77 73 20 54 68 75 | 20 4f 63 74 20 20 33 20 |news Thu| Oct 3 |
|00000060| 31 36 3a 34 34 3a 30 38 | 20 31 39 39 36 0a 58 72 |16:44:08| 1996.Xr|
|00000070| 65 66 3a 20 63 73 2e 76 | 75 2e 6e 6c 20 63 6f 6d |ef: cs.v|u.nl com|
|00000080| 70 2e 6c 61 6e 67 2e 70 | 79 74 68 6f 6e 3a 31 33 |p.lang.p|ython:13|
|00000090| 37 32 30 0a 50 61 74 68 | 3a 20 63 73 2e 76 75 2e |720.Path|: cs.vu.|
|000000a0| 6e 6c 21 73 75 6e 34 6e | 6c 21 45 55 2e 6e 65 74 |nl!sun4n|l!EU.net|
|000000b0| 21 65 6e 65 77 73 2e 73 | 67 69 2e 63 6f 6d 21 64 |!enews.s|gi.com!d|
|000000c0| 65 63 77 72 6c 21 70 61 | 67 65 73 61 74 2e 6e 65 |ecwrl!pa|gesat.ne|
|000000d0| 74 21 6e 65 77 73 2e 69 | 6e 63 6f 6e 6e 65 63 74 |t!news.i|nconnect|
|000000e0| 2e 63 6f 6d 21 6e 65 77 | 73 0a 46 72 6f 6d 3a 20 |.com!new|s.From: |
|000000f0| 22 6a 65 66 66 72 65 79 | 20 50 2e 20 53 68 65 6c |"jeffrey| P. Shel|
|00000100| 6c 22 20 3c 6a 65 66 66 | 40 63 79 6e 61 70 73 65 |l" <jeff|@cynapse|
|00000110| 73 2e 63 6f 6d 3e 0a 4e | 65 77 73 67 72 6f 75 70 |s.com>.N|ewsgroup|
|00000120| 73 3a 20 63 6f 6d 70 2e | 6c 61 6e 67 2e 70 79 74 |s: comp.|lang.pyt|
|00000130| 68 6f 6e 0a 53 75 62 6a | 65 63 74 3a 20 52 65 3a |hon.Subj|ect: Re:|
|00000140| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00000150| 69 6f 6e 73 0a 44 61 74 | 65 3a 20 57 65 64 2c 20 |ions.Dat|e: Wed, |
|00000160| 30 32 20 4f 63 74 20 31 | 39 39 36 20 30 37 3a 35 |02 Oct 1|996 07:5|
|00000170| 34 3a 31 39 20 2d 30 36 | 30 30 0a 4f 72 67 61 6e |4:19 -06|00.Organ|
|00000180| 69 7a 61 74 69 6f 6e 3a | 20 43 79 6e 61 70 73 65 |ization:| Cynapse|
|00000190| 73 20 2f 20 72 69 76 65 | 72 59 61 72 64 0a 4c 69 |s / rive|rYard.Li|
|000001a0| 6e 65 73 3a 20 38 34 0a | 4d 65 73 73 61 67 65 2d |nes: 84.|Message-|
|000001b0| 49 44 3a 20 3c 33 32 35 | 32 37 34 30 42 2e 36 42 |ID: <325|2740B.6B|
|000001c0| 34 39 40 63 79 6e 61 70 | 73 65 73 2e 63 6f 6d 3e |49@cynap|ses.com>|
|000001d0| 0a 52 65 66 65 72 65 6e | 63 65 73 3a 20 3c 33 32 |.Referen|ces: <32|
|000001e0| 35 31 46 42 33 33 2e 32 | 37 38 31 45 34 39 34 40 |51FB33.2|781E494@|
|000001f0| 74 75 62 65 2e 65 63 63 | 6f 73 79 73 2e 63 6f 6d |tube.ecc|osys.com|
|00000200| 3e 0a 4e 4e 54 50 2d 50 | 6f 73 74 69 6e 67 2d 48 |>.NNTP-P|osting-H|
|00000210| 6f 73 74 3a 20 73 6c 63 | 2d 64 69 61 6c 2d 32 33 |ost: slc|-dial-23|
|00000220| 2e 69 6e 63 6f 6e 6e 65 | 63 74 2e 63 6f 6d 0a 4d |.inconne|ct.com.M|
|00000230| 69 6d 65 2d 56 65 72 73 | 69 6f 6e 3a 20 31 2e 30 |ime-Vers|ion: 1.0|
|00000240| 0a 43 6f 6e 74 65 6e 74 | 2d 54 79 70 65 3a 20 74 |.Content|-Type: t|
|00000250| 65 78 74 2f 70 6c 61 69 | 6e 3b 20 63 68 61 72 73 |ext/plai|n; chars|
|00000260| 65 74 3d 75 73 2d 61 73 | 63 69 69 0a 43 6f 6e 74 |et=us-as|cii.Cont|
|00000270| 65 6e 74 2d 54 72 61 6e | 73 66 65 72 2d 45 6e 63 |ent-Tran|sfer-Enc|
|00000280| 6f 64 69 6e 67 3a 20 37 | 62 69 74 0a 58 2d 4d 61 |oding: 7|bit.X-Ma|
|00000290| 69 6c 65 72 3a 20 4d 6f | 7a 69 6c 6c 61 20 32 2e |iler: Mo|zilla 2.|
|000002a0| 30 32 20 28 4d 61 63 69 | 6e 74 6f 73 68 3b 20 49 |02 (Maci|ntosh; I|
|000002b0| 3b 20 36 38 4b 29 0a 54 | 6f 3a 20 41 64 61 6d 20 |; 68K).T|o: Adam |
|000002c0| 42 6a 6f 72 6e 68 6f 6c | 6d 20 3c 61 64 61 6d 40 |Bjornhol|m <adam@|
|000002d0| 74 75 62 65 2e 65 63 63 | 6f 73 79 73 2e 63 6f 6d |tube.ecc|osys.com|
|000002e0| 3e 0a 0a 3e 20 41 6e 79 | 6f 6e 65 20 6b 6e 6f 77 |>..> Any|one know|
|000002f0| 20 77 68 65 72 65 20 49 | 20 63 61 6e 20 67 65 74 | where I| can get|
|00000300| 20 61 6e 20 65 78 70 6c | 61 69 6e 61 74 69 6f 6e | an expl|aination|
|00000310| 20 6f 66 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 | of regu|lar expr|
|00000320| 65 73 73 69 6f 6e 73 3f | 0a 0a 74 68 65 72 65 27 |essions?|..there'|
|00000330| 73 20 61 20 72 65 61 6c | 6c 79 20 72 65 61 6c 6c |s a real|ly reall|
|00000340| 79 20 67 6f 6f 64 20 51 | 75 69 63 6b 52 65 66 65 |y good Q|uickRefe|
|00000350| 72 65 6e 63 65 20 64 6f | 63 75 6d 65 6e 74 20 74 |rence do|cument t|
|00000360| 68 61 74 20 63 6f 6e 74 | 61 69 6e 73 20 6c 6f 74 |hat cont|ains lot|
|00000370| 73 20 0a 6f 66 20 67 6f | 6f 64 20 69 6e 66 6f 72 |s .of go|od infor|
|00000380| 6d 61 74 69 6f 6e 20 6f | 6e 20 50 79 74 68 6f 6e |mation o|n Python|
|00000390| 2e 2e 20 20 4f 6e 65 20 | 6f 66 20 74 68 65 20 70 |.. One |of the p|
|000003a0| 6c 61 63 65 73 20 79 6f | 75 20 63 61 6e 20 72 65 |laces yo|u can re|
|000003b0| 61 64 20 74 68 65 20 0a | 65 6e 74 69 72 65 20 64 |ad the .|entire d|
|000003c0| 6f 63 75 6d 65 6e 74 20 | 69 73 20 3c 68 74 74 70 |ocument |is <http|
|000003d0| 3a 2f 2f 77 77 77 2e 63 | 79 6e 61 70 73 65 73 2e |://www.c|ynapses.|
|000003e0| 63 6f 6d 2f 72 79 2f 70 | 79 74 68 6f 6e 2f 70 79 |com/ry/p|ython/py|
|000003f0| 51 75 69 63 6b 52 65 66 | 2e 68 74 6d 6c 3e 2e 20 |QuickRef|.html>. |
|00000400| 20 0a 41 70 70 65 6e 64 | 69 78 20 33 20 6f 66 20 | .Append|ix 3 of |
|00000410| 22 69 6e 74 65 72 6e 65 | 74 20 70 72 6f 67 72 61 |"interne|t progra|
|00000420| 6d 6d 69 6e 67 20 77 69 | 74 68 20 50 79 74 68 6f |mming wi|th Pytho|
|00000430| 6e 22 20 69 73 20 6f 6e | 6c 69 6e 65 20 61 74 20 |n" is on|line at |
|00000440| 0a 77 77 77 2e 70 79 74 | 68 6f 6e 2e 6f 72 67 20 |.www.pyt|hon.org |
|00000450| 73 6f 6d 65 77 68 65 72 | 65 20 61 6e 64 20 65 78 |somewher|e and ex|
|00000460| 70 6c 61 69 6e 73 20 72 | 65 67 75 6c 61 72 20 65 |plains r|egular e|
|00000470| 78 70 72 65 73 73 69 6f | 6e 73 20 69 6e 20 50 79 |xpressio|ns in Py|
|00000480| 74 68 6f 6e 2e 0a 2d 2d | 20 0a 2e 6a 50 53 20 7c |thon..--| ..jPS ||
|00000490| 7c 20 6a 65 66 66 40 63 | 79 6e 61 70 73 65 73 2e || jeff@c|ynapses.|
|000004a0| 63 6f 6d 20 7c 7c 20 68 | 74 74 70 3a 2f 2f 77 77 |com || h|ttp://ww|
|000004b0| 77 2e 63 79 6e 61 70 73 | 65 73 2e 63 6f 6d 2f 72 |w.cynaps|es.com/r|
|000004c0| 79 2f 0a 0a 66 72 6f 6d | 20 74 68 65 20 51 75 69 |y/..from| the Qui|
|000004d0| 63 6b 20 52 65 66 65 72 | 65 6e 63 65 20 28 69 74 |ck Refer|ence (it|
|000004e0| 27 73 20 72 65 63 6f 6d | 6d 65 6e 64 65 64 20 79 |'s recom|mended y|
|000004f0| 6f 75 20 66 69 6e 64 20 | 74 68 61 74 20 73 65 63 |ou find |that sec|
|00000500| 74 69 6f 6e 20 6f 66 20 | 74 68 65 20 0a 62 6f 6f |tion of |the .boo|
|00000510| 6b 20 64 65 73 63 72 69 | 62 65 64 20 61 62 6f 76 |k descri|bed abov|
|00000520| 65 2c 20 69 74 20 68 61 | 73 20 70 6c 65 6e 74 79 |e, it ha|s plenty|
|00000530| 20 6f 66 20 65 78 61 6d | 70 6c 65 73 29 3a 0a 0a | of exam|ples):..|
|00000540| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|00000550| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000560| 20 20 20 20 20 20 20 72 | 65 67 65 78 0a 0a 50 61 | r|egex..Pa|
|00000570| 74 74 65 72 6e 73 20 61 | 72 65 20 73 70 65 63 69 |tterns a|re speci|
|00000580| 66 69 65 64 20 61 73 20 | 73 74 72 69 6e 67 73 2e |fied as |strings.|
|00000590| 20 44 65 66 61 75 6c 74 | 20 73 79 6e 74 61 78 20 | Default| syntax |
|000005a0| 69 73 20 65 6d 61 63 73 | 2d 73 74 79 6c 65 2e 20 |is emacs|-style. |
|000005b0| 0a 0a 53 70 65 63 69 61 | 6c 20 43 68 61 72 61 63 |..Specia|l Charac|
|000005c0| 74 65 72 73 20 28 75 73 | 69 6e 67 20 64 65 66 61 |ters (us|ing defa|
|000005d0| 75 6c 74 20 73 79 6e 74 | 61 78 29 3a 20 0a 0a 2e |ult synt|ax): ...|
|000005e0| 20 20 20 20 20 20 20 6d | 61 74 63 68 65 73 20 61 | m|atches a|
|000005f0| 6e 79 20 63 68 61 72 61 | 63 74 65 72 0a 2a 20 20 |ny chara|cter.* |
|00000600| 20 20 20 20 20 30 20 6f | 72 20 6d 6f 72 65 20 6f | 0 o|r more o|
|00000610| 66 20 70 72 65 63 65 65 | 64 69 6e 67 20 72 65 67 |f precee|ding reg|
|00000620| 75 6c 61 72 20 65 78 70 | 72 65 73 73 73 69 6f 6e |ular exp|resssion|
|00000630| 0a 2b 20 20 20 20 20 20 | 20 31 20 6f 72 20 6d 6f |.+ | 1 or mo|
|00000640| 72 65 20 6f 66 20 70 72 | 65 63 65 65 64 69 6e 67 |re of pr|eceeding|
|00000650| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00000660| 73 69 6f 6e 0a 3f 20 20 | 20 20 20 20 20 30 20 6f |sion.? | 0 o|
|00000670| 72 20 31 20 6f 66 20 70 | 72 65 63 65 65 64 69 6e |r 1 of p|receedin|
|00000680| 67 20 72 65 67 75 6c 61 | 72 20 65 78 70 72 65 73 |g regula|r expres|
|00000690| 73 73 69 6f 6e 0a 5b 20 | 5d 20 20 20 20 20 64 65 |ssion.[ |] de|
|000006a0| 66 69 6e 65 73 20 63 68 | 61 72 61 63 74 65 72 20 |fines ch|aracter |
|000006b0| 73 65 74 3a 20 27 5b 61 | 2d 7a 41 2d 5a 5d 27 20 |set: '[a|-zA-Z]' |
|000006c0| 74 6f 20 6d 61 74 63 68 | 20 61 6c 6c 20 6c 65 74 |to match| all let|
|000006d0| 74 65 72 73 0a 5b 5e 20 | 5d 20 20 20 20 64 65 66 |ters.[^ |] def|
|000006e0| 69 6e 65 73 20 63 6f 6d | 70 6c 65 6d 65 6e 74 65 |ines com|plemente|
|000006f0| 64 20 63 68 61 72 61 63 | 74 65 72 20 73 65 74 3a |d charac|ter set:|
|00000700| 20 6d 61 74 63 68 65 73 | 20 69 66 20 63 68 61 72 | matches| if char|
|00000710| 20 69 73 20 4e 4f 54 20 | 69 6e 20 0a 73 65 74 0a | is NOT |in .set.|
|00000720| 5e 20 20 20 20 20 20 20 | 6d 61 74 63 68 65 73 20 |^ |matches |
|00000730| 65 6d 70 74 79 20 73 74 | 72 20 61 74 20 62 65 67 |empty st|r at beg|
|00000740| 69 6e 6e 69 6e 67 20 6f | 66 20 6c 69 6e 65 0a 24 |inning o|f line.$|
|00000750| 20 20 20 20 20 20 20 6d | 61 74 63 68 65 73 20 65 | m|atches e|
|00000760| 6d 70 74 79 20 73 74 72 | 20 61 74 20 65 6e 64 20 |mpty str| at end |
|00000770| 6f 66 20 6c 69 6e 65 0a | 5c 20 20 20 20 20 20 20 |of line.|\ |
|00000780| 71 75 6f 74 69 6e 67 20 | 63 68 61 72 3a 20 5c 5b |quoting |char: \[|
|00000790| 20 6d 61 74 63 68 65 73 | 20 63 68 61 72 20 27 5b | matches| char '[|
|000007a0| 27 0a 5c 5c 20 20 20 20 | 20 20 6d 61 74 63 68 65 |'.\\ | matche|
|000007b0| 73 20 27 5c 27 3b 20 64 | 75 65 20 74 6f 20 50 79 |s '\'; d|ue to Py|
|000007c0| 74 68 6f 6e 20 73 74 72 | 69 6e 67 20 72 75 6c 65 |thon str|ing rule|
|000007d0| 73 2c 20 77 72 69 74 65 | 20 61 73 20 27 5c 5c 5c |s, write| as '\\\|
|000007e0| 5c 27 20 69 6e 0a 20 20 | 20 20 20 20 20 20 74 68 |\' in. | th|
|000007f0| 65 20 70 61 74 74 65 72 | 6e 20 73 74 72 69 6e 67 |e patter|n string|
|00000800| 2e 0a 5c 7c 20 20 20 20 | 20 20 73 70 65 63 69 66 |..\| | specif|
|00000810| 69 65 73 20 61 6c 74 65 | 72 6e 61 74 69 76 65 3a |ies alte|rnative:|
|00000820| 20 27 66 6f 6f 5c 7c 62 | 61 72 27 20 6d 61 74 63 | 'foo\|b|ar' matc|
|00000830| 68 65 73 20 27 66 6f 6f | 27 20 6f 72 20 27 62 61 |hes 'foo|' or 'ba|
|00000840| 72 27 0a 5c 28 20 5c 29 | 20 20 20 67 72 6f 75 70 |r'.\( \)| group|
|00000850| 69 6e 67 20 28 66 6f 72 | 20 5c 7c 2c 20 6f 72 20 |ing (for| \|, or |
|00000860| 63 6f 6d 70 6c 69 63 61 | 74 65 64 20 65 78 70 72 |complica|ted expr|
|00000870| 2c 20 6f 72 20 73 75 62 | 73 74 72 20 66 6f 72 20 |, or sub|str for |
|00000880| 66 75 74 75 72 65 0a 20 | 20 20 20 20 20 20 20 72 |future. | r|
|00000890| 65 66 65 72 65 6e 63 65 | 20 62 79 20 5c 44 20 63 |eference| by \D c|
|000008a0| 68 61 72 61 63 74 65 72 | 20 6f 72 20 67 72 6f 75 |haracter| or grou|
|000008b0| 70 28 29 20 6d 65 74 68 | 6f 64 29 0a 5c 44 20 20 |p() meth|od).\D |
|000008c0| 20 20 20 20 44 20 69 73 | 20 64 69 67 69 74 3a 20 | D is| digit: |
|000008d0| 6d 61 74 63 68 65 73 20 | 73 75 62 73 74 72 20 6d |matches |substr m|
|000008e0| 61 74 63 68 65 64 20 62 | 79 20 44 27 74 68 20 5c |atched b|y D'th \|
|000008f0| 28 20 5c 29 20 69 6e 20 | 70 61 74 74 65 72 6e 0a |( \) in |pattern.|
|00000900| 5c 60 20 20 20 20 20 20 | 65 6d 70 74 79 20 73 74 |\` |empty st|
|00000910| 72 20 61 74 20 62 65 67 | 69 6e 6e 69 6e 67 20 6f |r at beg|inning o|
|00000920| 66 20 66 69 6c 65 0a 5c | 27 20 20 20 20 20 20 65 |f file.\|' e|
|00000930| 6d 70 74 79 20 73 74 72 | 20 61 74 20 65 6e 64 20 |mpty str| at end |
|00000940| 6f 66 20 66 69 6c 65 0a | 5c 62 20 20 20 20 20 20 |of file.|\b |
|00000950| 65 6d 70 74 79 20 73 74 | 72 20 61 74 20 62 65 67 |empty st|r at beg|
|00000960| 20 6f 72 20 65 6e 64 20 | 6f 66 20 77 6f 72 64 3a | or end |of word:|
|00000970| 20 27 5c 62 69 73 5c 62 | 27 20 6d 61 74 63 68 65 | '\bis\b|' matche|
|00000980| 73 20 27 69 73 27 2c 20 | 62 75 74 20 6e 6f 74 20 |s 'is', |but not |
|00000990| 0a 27 68 69 73 27 0a 5c | 42 20 20 20 20 20 20 65 |.'his'.\|B e|
|000009a0| 6d 70 74 79 20 73 74 72 | 20 4e 4f 54 20 61 74 20 |mpty str| NOT at |
|000009b0| 62 65 67 69 6e 6e 69 6e | 67 20 6f 72 20 65 6e 64 |beginnin|g or end|
|000009c0| 20 6f 66 20 77 6f 72 64 | 0a 5c 3c 20 20 20 20 20 | of word|.\< |
|000009d0| 20 65 6d 70 74 79 20 73 | 74 72 20 61 74 20 62 65 | empty s|tr at be|
|000009e0| 67 69 6e 6e 69 6e 67 20 | 6f 66 20 77 6f 72 64 0a |ginning |of word.|
|000009f0| 5c 3e 20 20 20 20 20 20 | 65 6d 70 74 79 20 73 74 |\> |empty st|
|00000a00| 72 20 61 74 20 65 6e 64 | 20 6f 66 20 77 6f 72 64 |r at end| of word|
|00000a10| 0a 5c 77 20 20 20 20 20 | 20 61 6e 79 20 77 6f 72 |.\w | any wor|
|00000a20| 64 20 63 6f 6e 73 74 69 | 74 75 65 6e 74 0a 5c 57 |d consti|tuent.\W|
|00000a30| 20 20 20 20 20 20 61 6e | 79 20 6e 6f 6e 2d 77 6f | an|y non-wo|
|00000a40| 72 64 20 63 6f 6e 73 74 | 69 74 75 65 6e 74 0a 0a |rd const|ituent..|
|00000a50| 56 61 72 69 61 62 6c 65 | 73 3a 20 0a 0a 65 72 72 |Variable|s: ..err|
|00000a60| 6f 72 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |or | |
|00000a70| 20 20 20 20 20 2d 2d 20 | 45 78 63 65 70 74 69 6f | -- |Exceptio|
|00000a80| 6e 20 77 68 65 6e 20 70 | 61 74 74 65 72 6e 20 73 |n when p|attern s|
|00000a90| 74 72 69 6e 67 20 69 73 | 6e 27 74 20 76 61 6c 69 |tring is|n't vali|
|00000aa0| 64 20 0a 72 65 67 65 78 | 70 2e 0a 0a 46 75 6e 63 |d .regex|p...Func|
|00000ab0| 74 69 6f 6e 73 3a 0a 0a | 6d 61 74 63 68 28 70 61 |tions:..|match(pa|
|00000ac0| 74 74 65 72 6e 2c 20 73 | 74 72 69 6e 67 29 20 20 |ttern, s|tring) |
|00000ad0| 2d 2d 20 52 65 74 75 72 | 6e 20 68 6f 77 20 6d 61 |-- Retur|n how ma|
|00000ae0| 6e 79 20 63 68 61 72 61 | 63 74 65 72 73 20 61 74 |ny chara|cters at|
|00000af0| 20 74 68 65 20 62 65 67 | 69 6e 6e 69 6e 67 0a 20 | the beg|inning. |
|00000b00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000b10| 20 20 20 20 20 20 20 20 | 20 20 6f 66 20 3c 73 74 | | of <st|
|00000b20| 72 69 6e 67 3e 20 6d 61 | 74 63 68 20 72 65 67 65 |ring> ma|tch rege|
|00000b30| 78 70 20 3c 70 61 74 74 | 65 72 6e 3e 0a 20 20 20 |xp <patt|ern>. |
|00000b40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000b50| 20 20 20 20 20 20 20 20 | 6f 72 20 2d 31 20 69 66 | |or -1 if|
|00000b60| 20 6e 6f 6e 65 2e 0a 0a | 73 65 61 72 63 68 28 70 | none...|search(p|
|00000b70| 61 74 74 65 72 6e 2c 20 | 73 74 72 69 6e 67 20 5b |attern, |string [|
|00000b80| 2c 20 70 6f 73 5d 29 20 | 0a 20 20 20 20 20 20 20 |, pos]) |. |
|00000b90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000ba0| 20 2d 2d 20 52 65 74 75 | 72 6e 20 74 68 65 20 66 | -- Retu|rn the f|
|00000bb0| 69 72 73 74 20 70 6f 73 | 69 74 69 6f 6e 20 69 6e |irst pos|ition in|
|00000bc0| 20 3c 73 74 72 69 6e 67 | 3e 20 74 68 61 74 0a 20 | <string|> that. |
|00000bd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000be0| 20 20 20 20 20 20 20 20 | 20 20 6d 61 74 63 68 65 | | matche|
|00000bf0| 73 20 72 65 67 65 78 70 | 20 3c 70 61 74 74 65 72 |s regexp| <patter|
|00000c00| 6e 3e 2e 20 20 52 65 74 | 75 72 6e 20 2d 31 20 69 |n>. Ret|urn -1 i|
|00000c10| 66 20 6e 6f 6e 65 2e 0a | 20 20 20 20 20 20 20 20 |f none..| |
|00000c20| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000c30| 20 20 20 5b 73 74 61 72 | 74 69 6e 67 20 61 74 20 | [star|ting at |
|00000c40| 3c 70 6f 73 3e 2e 5d 0a | 0a 63 6f 6d 70 69 6c 65 |<pos>.].|.compile|
|00000c50| 28 70 61 74 74 65 72 6e | 20 5b 2c 74 72 61 6e 73 |(pattern| [,trans|
|00000c60| 6c 61 74 65 5d 29 0a 20 | 20 20 20 20 20 20 20 20 |late]). | |
|00000c70| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 2d | | -|
|00000c80| 2d 20 43 72 65 61 74 65 | 20 72 65 67 65 78 70 20 |- Create| regexp |
|00000c90| 6f 62 6a 65 63 74 20 74 | 68 61 74 20 68 61 73 20 |object t|hat has |
|00000ca0| 6d 65 74 68 6f 64 73 0a | 20 20 20 20 20 20 20 20 |methods.| |
|00000cb0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000cc0| 20 20 20 6d 61 74 63 68 | 28 29 20 61 6e 64 20 73 | match|() and s|
|00000cd0| 65 61 72 63 68 28 29 20 | 77 6f 72 6b 69 6e 67 20 |earch() |working |
|00000ce0| 61 73 20 61 62 6f 76 65 | 2e 20 41 6c 73 6f 0a 20 |as above|. Also. |
|00000cf0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000d00| 20 20 20 20 20 20 20 20 | 20 20 67 72 6f 75 70 28 | | group(|
|00000d10| 69 31 2c 20 5b 2c 69 32 | 5d 2a 29 2e 20 41 6c 73 |i1, [,i2|]*). Als|
|00000d20| 6f 20 72 65 67 73 2c 20 | 20 74 75 70 6c 65 20 6f |o regs, | tuple o|
|00000d30| 66 20 0a 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |f . | |
|00000d40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 70 6f | | po|
|00000d50| 73 69 74 69 6f 6e 73 20 | 6d 61 74 63 68 65 64 3b |sitions |matched;|
|00000d60| 20 72 65 67 73 5b 30 5d | 20 69 73 20 77 68 6f 6c | regs[0]| is whol|
|00000d70| 65 20 6d 61 74 63 68 2c | 20 0a 20 20 20 20 20 20 |e match,| . |
|00000d80| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000d90| 20 20 20 20 20 6e 65 78 | 74 20 61 72 65 20 73 75 | nex|t are su|
|00000da0| 62 65 78 70 72 65 73 73 | 69 6f 6e 73 2e 20 45 2e |bexpress|ions. E.|
|00000db0| 67 2e 0a 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |g.. | |
|00000dc0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 70 20 | | p |
|00000dd0| 3d 20 63 6f 6d 70 69 6c | 65 28 27 69 64 5c 28 5b |= compil|e('id\([|
|00000de0| 61 2d 7a 5d 5c 29 5c 28 | 5b 61 2d 7a 5d 5c 29 27 |a-z]\)\(|[a-z]\)'|
|00000df0| 29 0a 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |). | |
|00000e00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 70 2e 6d | | p.m|
|00000e10| 61 74 63 68 28 27 69 64 | 61 62 27 29 20 3d 3d 3e |atch('id|ab') ==>|
|00000e20| 20 34 0a 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | 4. | |
|00000e30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 70 2e | | p.|
|00000e40| 67 72 6f 75 70 28 31 2c | 20 32 29 20 3d 3d 3e 20 |group(1,| 2) ==> |
|00000e50| 28 27 61 27 2c 20 27 62 | 27 29 0a 20 20 20 20 20 |('a', 'b|'). |
|00000e60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000e70| 20 20 20 20 20 20 70 2e | 72 65 67 73 20 3d 3d 3e | p.|regs ==>|
|00000e80| 20 28 28 30 2c 20 34 29 | 2c 20 28 32 2c 20 33 29 | ((0, 4)|, (2, 3)|
|00000e90| 2c 20 28 33 2c 20 34 29 | 2c 20 2e 2e 2e 29 0a 0a |, (3, 4)|, ...)..|
|00000ea0| 73 65 74 5f 73 79 6e 74 | 61 78 28 66 6c 61 67 29 |set_synt|ax(flag)|
|00000eb0| 20 20 20 20 20 20 20 20 | 2d 2d 20 53 65 74 20 73 | |-- Set s|
|00000ec0| 79 6e 74 61 78 20 66 6c | 61 67 73 20 66 6f 72 20 |yntax fl|ags for |
|00000ed0| 66 75 74 75 72 65 20 63 | 61 6c 6c 73 20 74 6f 0a |future c|alls to.|
|00000ee0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000ef0| 20 20 20 20 20 20 20 20 | 20 20 20 6d 61 74 63 68 | | match|
|00000f00| 28 29 2c 20 73 65 61 72 | 63 68 28 29 20 61 6e 64 |(), sear|ch() and|
|00000f10| 20 63 6f 6d 70 69 6c 65 | 28 29 2e 20 52 65 74 75 | compile|(). Retu|
|00000f20| 72 6e 73 0a 20 20 20 20 | 20 20 20 20 20 20 20 20 |rns. | |
|00000f30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 63 | | c|
|00000f40| 75 72 72 65 6e 74 20 76 | 61 6c 75 65 2e 20 46 6c |urrent v|alue. Fl|
|00000f50| 61 67 73 20 69 6e 20 6d | 6f 64 75 6c 65 20 72 65 |ags in m|odule re|
|00000f60| 67 65 78 5f 73 79 6e 74 | 61 78 2e 0a 0a 73 79 6d |gex_synt|ax...sym|
|00000f70| 63 6f 6d 70 28 70 61 74 | 74 65 72 6e 20 5b 2c 74 |comp(pat|tern [,t|
|00000f80| 72 61 6e 73 6c 61 74 65 | 5d 29 0a 20 20 20 20 20 |ranslate|]). |
|00000f90| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000fa0| 20 20 20 2d 2d 20 4c 69 | 6b 65 20 63 6f 6d 70 69 | -- Li|ke compi|
|00000fb0| 6c 65 20 62 75 74 20 77 | 69 74 68 20 73 79 6d 62 |le but w|ith symb|
|00000fc0| 6f 6c 69 63 20 67 72 6f | 75 70 0a 20 20 20 20 20 |olic gro|up. |
|00000fd0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000fe0| 20 20 20 20 20 20 6e 61 | 6d 65 73 2e 20 4e 61 6d | na|mes. Nam|
|00000ff0| 65 73 20 69 6e 20 61 6e | 67 6c 65 20 62 72 61 63 |es in an|gle brac|
|00001000| 6b 65 74 73 2e 20 41 63 | 63 65 73 73 20 0a 20 20 |kets. Ac|cess . |
|00001010| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001020| 20 20 20 20 20 20 20 20 | 20 74 68 72 6f 75 67 68 | | through|
|00001030| 20 67 72 6f 75 70 20 6d | 65 74 68 6f 64 2e 20 45 | group m|ethod. E|
|00001040| 2e 67 2e 20 0a 20 20 20 | 20 20 20 20 20 20 20 20 |.g. . | |
|00001050| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001060| 70 20 3d 20 73 79 6d 63 | 6f 6d 70 28 27 69 64 5c |p = symc|omp('id\|
|00001070| 28 3c 6c 31 3e 5b 61 2d | 7a 5d 5c 29 5c 28 3c 6c |(<l1>[a-|z]\)\(<l|
|00001080| 32 3e 5b 61 2d 7a 5d 5c | 29 27 29 0a 20 20 20 20 |2>[a-z]\|)'). |
|00001090| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000010a0| 20 20 20 20 20 20 20 70 | 2e 6d 61 74 63 68 28 27 | p|.match('|
|000010b0| 69 64 61 62 27 29 20 3d | 3d 3e 20 34 0a 20 20 20 |idab') =|=> 4. |
|000010c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000010d0| 20 20 20 20 20 20 20 20 | 70 2e 67 72 6f 75 70 28 | |p.group(|
|000010e0| 27 6c 31 27 29 20 3d 3d | 3e 20 27 61 27 0a 0a |'l1') ==|> 'a'.. |
+--------+-------------------------+-------------------------+--------+--------+