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: LaTeX Document
(document/latex).
You can browse this item here: tex
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n Module| \sectco|
|00000020| 64 65 7b 72 65 67 65 78 | 7d 7d 0a 0a 5c 62 69 6d |de{regex|}}..\bim|
|00000030| 6f 64 69 6e 64 65 78 7b | 72 65 67 65 78 7d 0a 54 |odindex{|regex}.T|
|00000040| 68 69 73 20 6d 6f 64 75 | 6c 65 20 70 72 6f 76 69 |his modu|le provi|
|00000050| 64 65 73 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 |des regu|lar expr|
|00000060| 65 73 73 69 6f 6e 20 6d | 61 74 63 68 69 6e 67 20 |ession m|atching |
|00000070| 6f 70 65 72 61 74 69 6f | 6e 73 20 73 69 6d 69 6c |operatio|ns simil|
|00000080| 61 72 20 74 6f 0a 74 68 | 6f 73 65 20 66 6f 75 6e |ar to.th|ose foun|
|00000090| 64 20 69 6e 20 45 6d 61 | 63 73 2e 20 20 49 74 20 |d in Ema|cs. It |
|000000a0| 69 73 20 61 6c 77 61 79 | 73 20 61 76 61 69 6c 61 |is alway|s availa|
|000000b0| 62 6c 65 2e 0a 0a 42 79 | 20 64 65 66 61 75 6c 74 |ble...By| default|
|000000c0| 20 74 68 65 20 70 61 74 | 74 65 72 6e 73 20 61 72 | the pat|terns ar|
|000000d0| 65 20 45 6d 61 63 73 2d | 73 74 79 6c 65 20 72 65 |e Emacs-|style re|
|000000e0| 67 75 6c 61 72 20 65 78 | 70 72 65 73 73 69 6f 6e |gular ex|pression|
|000000f0| 73 0a 28 77 69 74 68 20 | 6f 6e 65 20 65 78 63 65 |s.(with |one exce|
|00000100| 70 74 69 6f 6e 29 2e 20 | 20 54 68 65 72 65 20 69 |ption). | There i|
|00000110| 73 0a 61 20 77 61 79 20 | 74 6f 20 63 68 61 6e 67 |s.a way |to chang|
|00000120| 65 20 74 68 65 20 73 79 | 6e 74 61 78 20 74 6f 20 |e the sy|ntax to |
|00000130| 6d 61 74 63 68 20 74 68 | 61 74 20 6f 66 20 73 65 |match th|at of se|
|00000140| 76 65 72 61 6c 20 77 65 | 6c 6c 2d 6b 6e 6f 77 6e |veral we|ll-known|
|00000150| 0a 5c 55 4e 49 58 7b 7d | 20 75 74 69 6c 69 74 69 |.\UNIX{}| utiliti|
|00000160| 65 73 2e 20 20 54 68 65 | 20 65 78 63 65 70 74 69 |es. The| excepti|
|00000170| 6f 6e 20 69 73 20 74 68 | 61 74 20 45 6d 61 63 73 |on is th|at Emacs|
|00000180| 27 20 5c 73 61 6d 70 7b | 5c 65 20 73 7d 0a 70 61 |' \samp{|\e s}.pa|
|00000190| 74 74 65 72 6e 20 69 73 | 20 6e 6f 74 20 73 75 70 |ttern is| not sup|
|000001a0| 70 6f 72 74 65 64 2c 20 | 73 69 6e 63 65 20 74 68 |ported, |since th|
|000001b0| 65 20 6f 72 69 67 69 6e | 61 6c 20 69 6d 70 6c 65 |e origin|al imple|
|000001c0| 6d 65 6e 74 61 74 69 6f | 6e 20 72 65 66 65 72 65 |mentatio|n refere|
|000001d0| 6e 63 65 73 0a 74 68 65 | 20 45 6d 61 63 73 20 73 |nces.the| Emacs s|
|000001e0| 79 6e 74 61 78 20 74 61 | 62 6c 65 73 2e 0a 0a 54 |yntax ta|bles...T|
|000001f0| 68 69 73 20 6d 6f 64 75 | 6c 65 20 69 73 20 38 2d |his modu|le is 8-|
|00000200| 62 69 74 20 63 6c 65 61 | 6e 3a 20 62 6f 74 68 20 |bit clea|n: both |
|00000210| 70 61 74 74 65 72 6e 73 | 20 61 6e 64 20 73 74 72 |patterns| and str|
|00000220| 69 6e 67 73 20 6d 61 79 | 20 63 6f 6e 74 61 69 6e |ings may| contain|
|00000230| 20 6e 75 6c 6c 0a 62 79 | 74 65 73 20 61 6e 64 20 | null.by|tes and |
|00000240| 63 68 61 72 61 63 74 65 | 72 73 20 77 68 6f 73 65 |characte|rs whose|
|00000250| 20 68 69 67 68 20 62 69 | 74 20 69 73 20 73 65 74 | high bi|t is set|
|00000260| 2e 0a 0a 5c 73 74 72 6f | 6e 67 7b 50 6c 65 61 73 |...\stro|ng{Pleas|
|00000270| 65 20 6e 6f 74 65 3a 7d | 20 54 68 65 72 65 20 69 |e note:}| There i|
|00000280| 73 20 61 20 6c 69 74 74 | 6c 65 2d 6b 6e 6f 77 6e |s a litt|le-known|
|00000290| 20 66 61 63 74 20 61 62 | 6f 75 74 20 50 79 74 68 | fact ab|out Pyth|
|000002a0| 6f 6e 20 73 74 72 69 6e | 67 0a 6c 69 74 65 72 61 |on strin|g.litera|
|000002b0| 6c 73 20 77 68 69 63 68 | 20 6d 65 61 6e 73 20 74 |ls which| means t|
|000002c0| 68 61 74 20 79 6f 75 20 | 64 6f 6e 27 74 20 75 73 |hat you |don't us|
|000002d0| 75 61 6c 6c 79 20 68 61 | 76 65 20 74 6f 20 77 6f |ually ha|ve to wo|
|000002e0| 72 72 79 20 61 62 6f 75 | 74 0a 64 6f 75 62 6c 69 |rry abou|t.doubli|
|000002f0| 6e 67 20 62 61 63 6b 73 | 6c 61 73 68 65 73 2c 20 |ng backs|lashes, |
|00000300| 65 76 65 6e 20 74 68 6f | 75 67 68 20 74 68 65 79 |even tho|ugh they|
|00000310| 20 61 72 65 20 75 73 65 | 64 20 74 6f 20 65 73 63 | are use|d to esc|
|00000320| 61 70 65 20 73 70 65 63 | 69 61 6c 0a 63 68 61 72 |ape spec|ial.char|
|00000330| 61 63 74 65 72 73 20 69 | 6e 20 73 74 72 69 6e 67 |acters i|n string|
|00000340| 20 6c 69 74 65 72 61 6c | 73 20 61 73 20 77 65 6c | literal|s as wel|
|00000350| 6c 20 61 73 20 69 6e 20 | 72 65 67 75 6c 61 72 20 |l as in |regular |
|00000360| 65 78 70 72 65 73 73 69 | 6f 6e 73 2e 20 20 54 68 |expressi|ons. Th|
|00000370| 69 73 0a 69 73 20 62 65 | 63 61 75 73 65 20 50 79 |is.is be|cause Py|
|00000380| 74 68 6f 6e 20 64 6f 65 | 73 6e 27 74 20 72 65 6d |thon doe|sn't rem|
|00000390| 6f 76 65 20 62 61 63 6b | 73 6c 61 73 68 65 73 20 |ove back|slashes |
|000003a0| 66 72 6f 6d 20 73 74 72 | 69 6e 67 20 6c 69 74 65 |from str|ing lite|
|000003b0| 72 61 6c 73 20 69 66 0a | 74 68 65 79 20 61 72 65 |rals if.|they are|
|000003c0| 20 66 6f 6c 6c 6f 77 65 | 64 20 62 79 20 61 6e 20 | followe|d by an |
|000003d0| 75 6e 72 65 63 6f 67 6e | 69 7a 65 64 20 65 73 63 |unrecogn|ized esc|
|000003e0| 61 70 65 20 63 68 61 72 | 61 63 74 65 72 2e 0a 5c |ape char|acter..\|
|000003f0| 65 6d 70 68 7b 48 6f 77 | 65 76 65 72 7d 2c 20 69 |emph{How|ever}, i|
|00000400| 66 20 79 6f 75 20 77 61 | 6e 74 20 74 6f 20 69 6e |f you wa|nt to in|
|00000410| 63 6c 75 64 65 20 61 20 | 6c 69 74 65 72 61 6c 20 |clude a |literal |
|00000420| 5c 64 66 6e 7b 62 61 63 | 6b 73 6c 61 73 68 7d 20 |\dfn{bac|kslash} |
|00000430| 69 6e 20 61 0a 72 65 67 | 75 6c 61 72 20 65 78 70 |in a.reg|ular exp|
|00000440| 72 65 73 73 69 6f 6e 20 | 72 65 70 72 65 73 65 6e |ression |represen|
|00000450| 74 65 64 20 61 73 20 61 | 20 73 74 72 69 6e 67 20 |ted as a| string |
|00000460| 6c 69 74 65 72 61 6c 2c | 20 79 6f 75 20 68 61 76 |literal,| you hav|
|00000470| 65 20 74 6f 0a 5c 65 6d | 70 68 7b 71 75 61 64 72 |e to.\em|ph{quadr|
|00000480| 75 70 6c 65 7d 20 69 74 | 2e 20 20 45 2e 67 2e 5c |uple} it|. E.g.\|
|00000490| 20 20 74 6f 20 65 78 74 | 72 61 63 74 20 5c 4c 61 | to ext|ract \La|
|000004a0| 54 65 58 5c 20 5c 73 61 | 6d 70 7b 5c 65 20 73 65 |TeX\ \sa|mp{\e se|
|000004b0| 63 74 69 6f 6e 5c 7b 7b | 5c 72 6d 0a 5c 6c 64 6f |ction\{{|\rm.\ldo|
|000004c0| 74 73 7d 5c 7d 7d 20 68 | 65 61 64 65 72 73 20 66 |ts}\}} h|eaders f|
|000004d0| 72 6f 6d 20 61 20 64 6f | 63 75 6d 65 6e 74 2c 20 |rom a do|cument, |
|000004e0| 79 6f 75 20 63 61 6e 20 | 75 73 65 20 74 68 69 73 |you can |use this|
|000004f0| 20 70 61 74 74 65 72 6e | 3a 0a 5c 63 6f 64 65 7b | pattern|:.\code{|
|00000500| 27 5c 65 20 5c 65 20 5c | 65 20 5c 65 20 73 65 63 |'\e \e \|e \e sec|
|00000510| 74 69 6f 6e 5c 7b 5c 65 | 20 28 2e 2a 5c 65 20 29 |tion\{\e| (.*\e )|
|00000520| 5c 7d 27 7d 2e 20 20 5c | 65 6d 70 68 7b 41 6e 6f |\}'}. \|emph{Ano|
|00000530| 74 68 65 72 20 65 78 63 | 65 70 74 69 6f 6e 3a 7d |ther exc|eption:}|
|00000540| 0a 74 68 65 20 65 73 63 | 61 70 65 20 73 65 71 75 |.the esc|ape sequ|
|00000550| 65 63 65 20 5c 73 61 6d | 70 7b 5c 65 20 62 7d 20 |ece \sam|p{\e b} |
|00000560| 69 73 20 73 69 67 6e 69 | 66 69 63 61 6e 74 20 69 |is signi|ficant i|
|00000570| 6e 20 73 74 72 69 6e 67 | 20 6c 69 74 65 72 61 6c |n string| literal|
|00000580| 73 0a 28 77 68 65 72 65 | 20 69 74 20 6d 65 61 6e |s.(where| it mean|
|00000590| 73 20 74 68 65 20 41 53 | 43 49 49 20 62 65 6c 6c |s the AS|CII bell|
|000005a0| 20 63 68 61 72 61 63 74 | 65 72 29 20 61 73 20 77 | charact|er) as w|
|000005b0| 65 6c 6c 20 61 73 20 69 | 6e 20 45 6d 61 63 73 20 |ell as i|n Emacs |
|000005c0| 72 65 67 75 6c 61 72 0a | 65 78 70 72 65 73 73 69 |regular.|expressi|
|000005d0| 6f 6e 73 20 28 77 68 65 | 72 65 20 69 74 20 73 74 |ons (whe|re it st|
|000005e0| 61 6e 64 73 20 66 6f 72 | 20 61 20 77 6f 72 64 20 |ands for| a word |
|000005f0| 62 6f 75 6e 64 61 72 79 | 29 2c 20 73 6f 20 69 6e |boundary|), so in|
|00000600| 20 6f 72 64 65 72 20 74 | 6f 0a 73 65 61 72 63 68 | order t|o.search|
|00000610| 20 66 6f 72 20 61 20 77 | 6f 72 64 20 62 6f 75 6e | for a w|ord boun|
|00000620| 64 61 72 79 2c 20 79 6f | 75 20 73 68 6f 75 6c 64 |dary, yo|u should|
|00000630| 20 75 73 65 20 74 68 65 | 20 70 61 74 74 65 72 6e | use the| pattern|
|00000640| 20 5c 63 6f 64 65 7b 27 | 5c 65 20 5c 65 20 62 27 | \code{'|\e \e b'|
|00000650| 7d 2e 0a 53 69 6d 69 6c | 61 72 6c 79 2c 20 61 20 |}..Simil|arly, a |
|00000660| 62 61 63 6b 73 6c 61 73 | 68 20 66 6f 6c 6c 6f 77 |backslas|h follow|
|00000670| 65 64 20 62 79 20 61 20 | 64 69 67 69 74 20 30 2d |ed by a |digit 0-|
|00000680| 37 20 73 68 6f 75 6c 64 | 20 62 65 20 64 6f 75 62 |7 should| be doub|
|00000690| 6c 65 64 20 74 6f 0a 61 | 76 6f 69 64 20 69 6e 74 |led to.a|void int|
|000006a0| 65 72 70 72 65 74 61 74 | 69 6f 6e 20 61 73 20 61 |erpretat|ion as a|
|000006b0| 6e 20 6f 63 74 61 6c 20 | 65 73 63 61 70 65 2e 0a |n octal |escape..|
|000006c0| 0a 5c 73 75 62 73 65 63 | 74 69 6f 6e 7b 52 65 67 |.\subsec|tion{Reg|
|000006d0| 75 6c 61 72 20 45 78 70 | 72 65 73 73 69 6f 6e 73 |ular Exp|ressions|
|000006e0| 7d 0a 0a 41 20 72 65 67 | 75 6c 61 72 20 65 78 70 |}..A reg|ular exp|
|000006f0| 72 65 73 73 69 6f 6e 20 | 28 6f 72 20 52 45 29 20 |ression |(or RE) |
|00000700| 73 70 65 63 69 66 69 65 | 73 20 61 20 73 65 74 20 |specifie|s a set |
|00000710| 6f 66 20 73 74 72 69 6e | 67 73 20 74 68 61 74 20 |of strin|gs that |
|00000720| 6d 61 74 63 68 65 73 0a | 69 74 3b 20 74 68 65 20 |matches.|it; the |
|00000730| 66 75 6e 63 74 69 6f 6e | 73 20 69 6e 20 74 68 69 |function|s in thi|
|00000740| 73 20 6d 6f 64 75 6c 65 | 20 6c 65 74 20 79 6f 75 |s module| let you|
|00000750| 20 63 68 65 63 6b 20 69 | 66 20 61 20 70 61 72 74 | check i|f a part|
|00000760| 69 63 75 6c 61 72 20 73 | 74 72 69 6e 67 0a 6d 61 |icular s|tring.ma|
|00000770| 74 63 68 65 73 20 61 20 | 67 69 76 65 6e 20 72 65 |tches a |given re|
|00000780| 67 75 6c 61 72 20 65 78 | 70 72 65 73 73 69 6f 6e |gular ex|pression|
|00000790| 20 28 6f 72 20 69 66 20 | 61 20 67 69 76 65 6e 20 | (or if |a given |
|000007a0| 72 65 67 75 6c 61 72 20 | 65 78 70 72 65 73 73 69 |regular |expressi|
|000007b0| 6f 6e 0a 6d 61 74 63 68 | 65 73 20 61 20 70 61 72 |on.match|es a par|
|000007c0| 74 69 63 75 6c 61 72 20 | 73 74 72 69 6e 67 2c 20 |ticular |string, |
|000007d0| 77 68 69 63 68 20 63 6f | 6d 65 73 20 64 6f 77 6e |which co|mes down|
|000007e0| 20 74 6f 20 74 68 65 20 | 73 61 6d 65 20 74 68 69 | to the |same thi|
|000007f0| 6e 67 29 2e 0a 0a 52 65 | 67 75 6c 61 72 20 65 78 |ng)...Re|gular ex|
|00000800| 70 72 65 73 73 69 6f 6e | 73 20 63 61 6e 20 62 65 |pression|s can be|
|00000810| 20 63 6f 6e 63 61 74 65 | 6e 61 74 65 64 20 74 6f | concate|nated to|
|00000820| 20 66 6f 72 6d 20 6e 65 | 77 20 72 65 67 75 6c 61 | form ne|w regula|
|00000830| 72 0a 65 78 70 72 65 73 | 73 69 6f 6e 73 3b 20 69 |r.expres|sions; i|
|00000840| 66 20 5c 65 6d 70 68 7b | 41 7d 20 61 6e 64 20 5c |f \emph{|A} and \|
|00000850| 65 6d 70 68 7b 42 7d 20 | 61 72 65 20 62 6f 74 68 |emph{B} |are both|
|00000860| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00000870| 69 6f 6e 73 2c 0a 74 68 | 65 6e 20 5c 65 6d 70 68 |ions,.th|en \emph|
|00000880| 7b 41 42 7d 20 69 73 20 | 61 6c 73 6f 20 61 6e 20 |{AB} is |also an |
|00000890| 72 65 67 75 6c 61 72 20 | 65 78 70 72 65 73 73 69 |regular |expressi|
|000008a0| 6f 6e 2e 20 20 49 66 20 | 61 20 73 74 72 69 6e 67 |on. If |a string|
|000008b0| 20 5c 65 6d 70 68 7b 70 | 7d 0a 6d 61 74 63 68 65 | \emph{p|}.matche|
|000008c0| 73 20 41 20 61 6e 64 20 | 61 6e 6f 74 68 65 72 20 |s A and |another |
|000008d0| 73 74 72 69 6e 67 20 5c | 65 6d 70 68 7b 71 7d 20 |string \|emph{q} |
|000008e0| 6d 61 74 63 68 65 73 20 | 42 2c 20 74 68 65 20 73 |matches |B, the s|
|000008f0| 74 72 69 6e 67 20 5c 65 | 6d 70 68 7b 70 71 7d 0a |tring \e|mph{pq}.|
|00000900| 77 69 6c 6c 20 6d 61 74 | 63 68 20 41 42 2e 20 20 |will mat|ch AB. |
|00000910| 54 68 75 73 2c 20 63 6f | 6d 70 6c 65 78 20 65 78 |Thus, co|mplex ex|
|00000920| 70 72 65 73 73 69 6f 6e | 73 20 63 61 6e 20 65 61 |pression|s can ea|
|00000930| 73 69 6c 79 20 62 65 20 | 63 6f 6e 73 74 72 75 63 |sily be |construc|
|00000940| 74 65 64 0a 66 72 6f 6d | 20 73 69 6d 70 6c 65 72 |ted.from| simpler|
|00000950| 20 6f 6e 65 73 20 6c 69 | 6b 65 20 74 68 65 20 70 | ones li|ke the p|
|00000960| 72 69 6d 69 74 69 76 65 | 73 20 64 65 73 63 72 69 |rimitive|s descri|
|00000970| 62 65 64 20 68 65 72 65 | 2e 20 20 46 6f 72 20 64 |bed here|. For d|
|00000980| 65 74 61 69 6c 73 20 6f | 66 0a 74 68 65 20 74 68 |etails o|f.the th|
|00000990| 65 6f 72 79 20 61 6e 64 | 20 69 6d 70 6c 65 6d 65 |eory and| impleme|
|000009a0| 6e 74 61 74 69 6f 6e 20 | 6f 66 20 72 65 67 75 6c |ntation |of regul|
|000009b0| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 73 2c 20 |ar expre|ssions, |
|000009c0| 63 6f 6e 73 75 6c 74 20 | 61 6c 6d 6f 73 74 0a 61 |consult |almost.a|
|000009d0| 6e 79 20 74 65 78 74 62 | 6f 6f 6b 20 61 62 6f 75 |ny textb|ook abou|
|000009e0| 74 20 63 6f 6d 70 69 6c | 65 72 20 63 6f 6e 73 74 |t compil|er const|
|000009f0| 72 75 63 74 69 6f 6e 2e | 0a 0a 25 20 58 58 58 20 |ruction.|..% XXX |
|00000a00| 54 68 65 20 72 65 66 65 | 72 65 6e 63 65 20 63 6f |The refe|rence co|
|00000a10| 75 6c 64 20 62 65 20 6d | 61 64 65 20 6d 6f 72 65 |uld be m|ade more|
|00000a20| 20 73 70 65 63 69 66 69 | 63 2c 20 73 61 79 20 74 | specifi|c, say t|
|00000a30| 6f 20 0a 25 20 22 43 6f | 6d 70 69 6c 65 72 73 3a |o .% "Co|mpilers:|
|00000a40| 20 50 72 69 6e 63 69 70 | 6c 65 73 2c 20 54 65 63 | Princip|les, Tec|
|00000a50| 68 6e 69 71 75 65 73 20 | 61 6e 64 20 54 6f 6f 6c |hniques |and Tool|
|00000a60| 73 22 2c 20 62 79 20 41 | 6c 66 72 65 64 20 56 2e |s", by A|lfred V.|
|00000a70| 20 41 68 6f 2c 20 0a 25 | 20 52 61 76 69 20 53 65 | Aho, .%| Ravi Se|
|00000a80| 74 68 69 2c 20 61 6e 64 | 20 4a 65 66 66 72 65 79 |thi, and| Jeffrey|
|00000a90| 20 44 2e 20 55 6c 6c 6d | 61 6e 2c 20 6f 72 20 73 | D. Ullm|an, or s|
|00000aa0| 6f 6d 65 20 46 41 20 74 | 65 78 74 2e 20 20 20 0a |ome FA t|ext. .|
|00000ab0| 0a 41 20 62 72 69 65 66 | 20 65 78 70 6c 61 6e 61 |.A brief| explana|
|00000ac0| 74 69 6f 6e 20 6f 66 20 | 74 68 65 20 66 6f 72 6d |tion of |the form|
|00000ad0| 61 74 20 6f 66 20 72 65 | 67 75 6c 61 72 20 65 78 |at of re|gular ex|
|00000ae0| 70 72 65 73 73 69 6f 6e | 73 20 66 6f 6c 6c 6f 77 |pression|s follow|
|00000af0| 73 2e 0a 0a 52 65 67 75 | 6c 61 72 20 65 78 70 72 |s...Regu|lar expr|
|00000b00| 65 73 73 69 6f 6e 73 20 | 63 61 6e 20 63 6f 6e 74 |essions |can cont|
|00000b10| 61 69 6e 20 62 6f 74 68 | 20 73 70 65 63 69 61 6c |ain both| special|
|00000b20| 20 61 6e 64 20 6f 72 64 | 69 6e 61 72 79 20 63 68 | and ord|inary ch|
|00000b30| 61 72 61 63 74 65 72 73 | 2e 0a 4f 72 64 69 6e 61 |aracters|..Ordina|
|00000b40| 72 79 20 63 68 61 72 61 | 63 74 65 72 73 2c 20 6c |ry chara|cters, l|
|00000b50| 69 6b 65 20 27 5c 63 6f | 64 65 7b 41 7d 27 2c 20 |ike '\co|de{A}', |
|00000b60| 27 5c 63 6f 64 65 7b 61 | 7d 27 2c 20 6f 72 20 27 |'\code{a|}', or '|
|00000b70| 5c 63 6f 64 65 7b 30 7d | 27 2c 20 61 72 65 0a 74 |\code{0}|', are.t|
|00000b80| 68 65 20 73 69 6d 70 6c | 65 73 74 20 72 65 67 75 |he simpl|est regu|
|00000b90| 6c 61 72 20 65 78 70 72 | 65 73 73 69 6f 6e 73 3b |lar expr|essions;|
|00000ba0| 20 74 68 65 79 20 73 69 | 6d 70 6c 79 20 6d 61 74 | they si|mply mat|
|00000bb0| 63 68 20 74 68 65 6d 73 | 65 6c 76 65 73 2e 20 20 |ch thems|elves. |
|00000bc0| 59 6f 75 0a 63 61 6e 20 | 63 6f 6e 63 61 74 65 6e |You.can |concaten|
|00000bd0| 61 74 65 20 6f 72 64 69 | 6e 61 72 79 20 63 68 61 |ate ordi|nary cha|
|00000be0| 72 61 63 74 65 72 73 2c | 20 73 6f 20 27 5c 63 6f |racters,| so '\co|
|00000bf0| 64 65 7b 6c 61 73 74 7d | 27 20 6d 61 74 63 68 65 |de{last}|' matche|
|00000c00| 73 20 74 68 65 0a 63 68 | 61 72 61 63 74 65 72 73 |s the.ch|aracters|
|00000c10| 20 27 6c 61 73 74 27 2e | 20 20 28 49 6e 20 74 68 | 'last'.| (In th|
|00000c20| 65 20 72 65 73 74 20 6f | 66 20 74 68 69 73 20 73 |e rest o|f this s|
|00000c30| 65 63 74 69 6f 6e 2c 20 | 77 65 27 6c 6c 20 77 72 |ection, |we'll wr|
|00000c40| 69 74 65 20 52 45 27 73 | 20 69 6e 0a 5c 63 6f 64 |ite RE's| in.\cod|
|00000c50| 65 7b 74 68 69 73 20 73 | 70 65 63 69 61 6c 20 66 |e{this s|pecial f|
|00000c60| 6f 6e 74 7d 2c 20 75 73 | 75 61 6c 6c 79 20 77 69 |ont}, us|ually wi|
|00000c70| 74 68 6f 75 74 20 71 75 | 6f 74 65 73 2c 20 61 6e |thout qu|otes, an|
|00000c80| 64 20 73 74 72 69 6e 67 | 73 20 74 6f 20 62 65 0a |d string|s to be.|
|00000c90| 6d 61 74 63 68 65 64 20 | 27 69 6e 20 73 69 6e 67 |matched |'in sing|
|00000ca0| 6c 65 20 71 75 6f 74 65 | 73 27 2e 29 0a 0a 53 70 |le quote|s'.)..Sp|
|00000cb0| 65 63 69 61 6c 20 63 68 | 61 72 61 63 74 65 72 73 |ecial ch|aracters|
|00000cc0| 20 65 69 74 68 65 72 20 | 73 74 61 6e 64 20 66 6f | either |stand fo|
|00000cd0| 72 20 63 6c 61 73 73 65 | 73 20 6f 66 20 6f 72 64 |r classe|s of ord|
|00000ce0| 69 6e 61 72 79 20 63 68 | 61 72 61 63 74 65 72 73 |inary ch|aracters|
|00000cf0| 2c 20 6f 72 0a 61 66 66 | 65 63 74 20 68 6f 77 20 |, or.aff|ect how |
|00000d00| 74 68 65 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 |the regu|lar expr|
|00000d10| 65 73 73 69 6f 6e 73 20 | 61 72 6f 75 6e 64 20 74 |essions |around t|
|00000d20| 68 65 6d 20 61 72 65 20 | 69 6e 74 65 72 70 72 65 |hem are |interpre|
|00000d30| 74 65 64 2e 0a 0a 54 68 | 65 20 73 70 65 63 69 61 |ted...Th|e specia|
|00000d40| 6c 20 63 68 61 72 61 63 | 74 65 72 73 20 61 72 65 |l charac|ters are|
|00000d50| 3a 0a 5c 62 65 67 69 6e | 7b 69 74 65 6d 69 7a 65 |:.\begin|{itemize|
|00000d60| 7d 0a 5c 69 74 65 6d 5b | 5c 63 6f 64 65 7b 2e 7d |}.\item[|\code{.}|
|00000d70| 5d 7b 28 44 6f 74 2e 29 | 20 20 4d 61 74 63 68 65 |]{(Dot.)| Matche|
|00000d80| 73 20 61 6e 79 20 63 68 | 61 72 61 63 74 65 72 20 |s any ch|aracter |
|00000d90| 65 78 63 65 70 74 20 61 | 20 6e 65 77 6c 69 6e 65 |except a| newline|
|00000da0| 2e 7d 0a 5c 69 74 65 6d | 5b 5c 63 6f 64 65 7b 5c |.}.\item|[\code{\|
|00000db0| 5e 7d 5d 7b 28 43 61 72 | 65 74 2e 29 20 20 4d 61 |^}]{(Car|et.) Ma|
|00000dc0| 74 63 68 65 73 20 74 68 | 65 20 73 74 61 72 74 20 |tches th|e start |
|00000dd0| 6f 66 20 74 68 65 20 73 | 74 72 69 6e 67 2e 7d 0a |of the s|tring.}.|
|00000de0| 5c 69 74 65 6d 5b 5c 63 | 6f 64 65 7b 5c 24 7d 5d |\item[\c|ode{\$}]|
|00000df0| 7b 4d 61 74 63 68 65 73 | 20 74 68 65 20 65 6e 64 |{Matches| the end|
|00000e00| 20 6f 66 20 74 68 65 20 | 73 74 72 69 6e 67 2e 20 | of the |string. |
|00000e10| 20 0a 5c 63 6f 64 65 7b | 66 6f 6f 7d 20 6d 61 74 | .\code{|foo} mat|
|00000e20| 63 68 65 73 20 62 6f 74 | 68 20 27 66 6f 6f 27 20 |ches bot|h 'foo' |
|00000e30| 61 6e 64 20 27 66 6f 6f | 62 61 72 27 2c 20 77 68 |and 'foo|bar', wh|
|00000e40| 69 6c 65 20 74 68 65 20 | 72 65 67 75 6c 61 72 0a |ile the |regular.|
|00000e50| 65 78 70 72 65 73 73 69 | 6f 6e 20 27 5c 63 6f 64 |expressi|on '\cod|
|00000e60| 65 7b 66 6f 6f 5c 24 7d | 27 20 6d 61 74 63 68 65 |e{foo\$}|' matche|
|00000e70| 73 20 6f 6e 6c 79 20 27 | 66 6f 6f 27 2e 7d 0a 5c |s only '|foo'.}.\|
|00000e80| 69 74 65 6d 5b 5c 63 6f | 64 65 7b 2a 7d 5d 20 43 |item[\co|de{*}] C|
|00000e90| 61 75 73 65 73 20 74 68 | 65 20 72 65 73 75 6c 74 |auses th|e result|
|00000ea0| 69 6e 67 20 52 45 20 74 | 6f 0a 6d 61 74 63 68 20 |ing RE t|o.match |
|00000eb0| 30 20 6f 72 20 6d 6f 72 | 65 20 72 65 70 65 74 69 |0 or mor|e repeti|
|00000ec0| 74 69 6f 6e 73 20 6f 66 | 20 74 68 65 20 70 72 65 |tions of| the pre|
|00000ed0| 63 65 64 69 6e 67 20 52 | 45 2e 20 20 5c 63 6f 64 |ceding R|E. \cod|
|00000ee0| 65 7b 61 62 2a 7d 20 77 | 69 6c 6c 0a 6d 61 74 63 |e{ab*} w|ill.matc|
|00000ef0| 68 20 27 61 27 2c 20 27 | 61 62 27 2c 20 6f 72 20 |h 'a', '|ab', or |
|00000f00| 27 61 27 20 66 6f 6c 6c | 6f 77 65 64 20 62 79 20 |'a' foll|owed by |
|00000f10| 61 6e 79 20 6e 75 6d 62 | 65 72 20 6f 66 20 27 62 |any numb|er of 'b|
|00000f20| 27 73 2e 0a 5c 69 74 65 | 6d 5b 5c 63 6f 64 65 7b |'s..\ite|m[\code{|
|00000f30| 2b 7d 5d 20 43 61 75 73 | 65 73 20 74 68 65 0a 72 |+}] Caus|es the.r|
|00000f40| 65 73 75 6c 74 69 6e 67 | 20 52 45 20 74 6f 20 6d |esulting| RE to m|
|00000f50| 61 74 63 68 20 31 20 6f | 72 20 6d 6f 72 65 20 72 |atch 1 o|r more r|
|00000f60| 65 70 65 74 69 74 69 6f | 6e 73 20 6f 66 20 74 68 |epetitio|ns of th|
|00000f70| 65 20 70 72 65 63 65 64 | 69 6e 67 20 52 45 2e 0a |e preced|ing RE..|
|00000f80| 5c 63 6f 64 65 7b 61 62 | 2b 7d 20 77 69 6c 6c 20 |\code{ab|+} will |
|00000f90| 6d 61 74 63 68 20 27 61 | 27 20 66 6f 6c 6c 6f 77 |match 'a|' follow|
|00000fa0| 65 64 20 62 79 20 61 6e | 79 20 6e 6f 6e 2d 7a 65 |ed by an|y non-ze|
|00000fb0| 72 6f 20 6e 75 6d 62 65 | 72 20 6f 66 20 27 62 27 |ro numbe|r of 'b'|
|00000fc0| 73 3b 20 69 74 0a 77 69 | 6c 6c 20 6e 6f 74 20 6d |s; it.wi|ll not m|
|00000fd0| 61 74 63 68 20 6a 75 73 | 74 20 27 61 27 2e 0a 5c |atch jus|t 'a'..\|
|00000fe0| 69 74 65 6d 5b 5c 63 6f | 64 65 7b 3f 7d 5d 20 43 |item[\co|de{?}] C|
|00000ff0| 61 75 73 65 73 20 74 68 | 65 20 72 65 73 75 6c 74 |auses th|e result|
|00001000| 69 6e 67 20 52 45 20 74 | 6f 0a 6d 61 74 63 68 20 |ing RE t|o.match |
|00001010| 30 20 6f 72 20 31 20 72 | 65 70 65 74 69 74 69 6f |0 or 1 r|epetitio|
|00001020| 6e 73 20 6f 66 20 74 68 | 65 20 70 72 65 63 65 64 |ns of th|e preced|
|00001030| 69 6e 67 20 52 45 2e 20 | 20 5c 63 6f 64 65 7b 61 |ing RE. | \code{a|
|00001040| 62 3f 7d 20 77 69 6c 6c | 0a 6d 61 74 63 68 20 65 |b?} will|.match e|
|00001050| 69 74 68 65 72 20 27 61 | 27 20 6f 72 20 27 61 62 |ither 'a|' or 'ab|
|00001060| 27 2e 0a 0a 5c 69 74 65 | 6d 5b 5c 63 6f 64 65 7b |'...\ite|m[\code{|
|00001070| 5c 65 7d 5d 20 45 69 74 | 68 65 72 20 65 73 63 61 |\e}] Eit|her esca|
|00001080| 70 65 73 20 73 70 65 63 | 69 61 6c 20 63 68 61 72 |pes spec|ial char|
|00001090| 61 63 74 65 72 73 20 28 | 70 65 72 6d 69 74 74 69 |acters (|permitti|
|000010a0| 6e 67 20 79 6f 75 20 74 | 6f 20 6d 61 74 63 68 0a |ng you t|o match.|
|000010b0| 63 68 61 72 61 63 74 65 | 72 73 20 6c 69 6b 65 20 |characte|rs like |
|000010c0| 27 2a 3f 2b 5c 26 5c 24 | 27 29 2c 20 6f 72 20 73 |'*?+\&\$|'), or s|
|000010d0| 69 67 6e 61 6c 73 20 61 | 20 73 70 65 63 69 61 6c |ignals a| special|
|000010e0| 20 73 65 71 75 65 6e 63 | 65 3b 20 73 70 65 63 69 | sequenc|e; speci|
|000010f0| 61 6c 0a 73 65 71 75 65 | 6e 63 65 73 20 61 72 65 |al.seque|nces are|
|00001100| 20 64 69 73 63 75 73 73 | 65 64 20 62 65 6c 6f 77 | discuss|ed below|
|00001110| 2e 20 20 52 65 6d 65 6d | 62 65 72 20 74 68 61 74 |. Remem|ber that|
|00001120| 20 50 79 74 68 6f 6e 20 | 61 6c 73 6f 20 75 73 65 | Python |also use|
|00001130| 73 20 74 68 65 0a 62 61 | 63 6b 73 6c 61 73 68 20 |s the.ba|ckslash |
|00001140| 61 73 20 61 6e 20 65 73 | 63 61 70 65 20 73 65 71 |as an es|cape seq|
|00001150| 75 65 6e 63 65 20 69 6e | 20 73 74 72 69 6e 67 20 |uence in| string |
|00001160| 6c 69 74 65 72 61 6c 73 | 3b 20 69 66 20 74 68 65 |literals|; if the|
|00001170| 20 65 73 63 61 70 65 0a | 73 65 71 75 65 6e 63 65 | escape.|sequence|
|00001180| 20 69 73 6e 27 74 20 72 | 65 63 6f 67 6e 69 7a 65 | isn't r|ecognize|
|00001190| 64 20 62 79 20 50 79 74 | 68 6f 6e 27 73 20 70 61 |d by Pyt|hon's pa|
|000011a0| 72 73 65 72 2c 20 74 68 | 65 20 62 61 63 6b 73 6c |rser, th|e backsl|
|000011b0| 61 73 68 20 61 6e 64 0a | 73 75 62 73 65 71 75 65 |ash and.|subseque|
|000011c0| 6e 74 20 63 68 61 72 61 | 63 74 65 72 20 61 72 65 |nt chara|cter are|
|000011d0| 20 69 6e 63 6c 75 64 65 | 64 20 69 6e 20 74 68 65 | include|d in the|
|000011e0| 20 72 65 73 75 6c 74 69 | 6e 67 20 73 74 72 69 6e | resulti|ng strin|
|000011f0| 67 2e 20 20 48 6f 77 65 | 76 65 72 2c 0a 69 66 20 |g. Howe|ver,.if |
|00001200| 50 79 74 68 6f 6e 20 77 | 6f 75 6c 64 20 72 65 63 |Python w|ould rec|
|00001210| 6f 67 6e 69 7a 65 20 74 | 68 65 20 72 65 73 75 6c |ognize t|he resul|
|00001220| 74 69 6e 67 20 73 65 71 | 75 65 6e 63 65 2c 20 74 |ting seq|uence, t|
|00001230| 68 65 20 62 61 63 6b 73 | 6c 61 73 68 20 73 68 6f |he backs|lash sho|
|00001240| 75 6c 64 0a 62 65 20 72 | 65 70 65 61 74 65 64 20 |uld.be r|epeated |
|00001250| 74 77 69 63 65 2e 20 20 | 0a 0a 5c 69 74 65 6d 5b |twice. |..\item[|
|00001260| 5c 63 6f 64 65 7b 5b 5d | 7d 5d 20 55 73 65 64 20 |\code{[]|}] Used |
|00001270| 74 6f 20 69 6e 64 69 63 | 61 74 65 20 61 20 73 65 |to indic|ate a se|
|00001280| 74 20 6f 66 20 63 68 61 | 72 61 63 74 65 72 73 2e |t of cha|racters.|
|00001290| 20 20 43 68 61 72 61 63 | 74 65 72 73 20 63 61 6e | Charac|ters can|
|000012a0| 0a 62 65 20 6c 69 73 74 | 65 64 20 69 6e 64 69 76 |.be list|ed indiv|
|000012b0| 69 64 75 61 6c 6c 79 2c | 20 6f 72 20 61 20 72 61 |idually,| or a ra|
|000012c0| 6e 67 65 20 69 73 20 69 | 6e 64 69 63 61 74 65 64 |nge is i|ndicated|
|000012d0| 20 62 79 20 67 69 76 69 | 6e 67 20 74 77 6f 0a 63 | by givi|ng two.c|
|000012e0| 68 61 72 61 63 74 65 72 | 73 20 61 6e 64 20 73 65 |haracter|s and se|
|000012f0| 70 61 72 61 74 69 6e 67 | 20 74 68 65 6d 20 62 79 |parating| them by|
|00001300| 20 61 20 27 2d 27 2e 20 | 20 53 70 65 63 69 61 6c | a '-'. | Special|
|00001310| 20 63 68 61 72 61 63 74 | 65 72 73 20 61 72 65 0a | charact|ers are.|
|00001320| 6e 6f 74 20 61 63 74 69 | 76 65 20 69 6e 73 69 64 |not acti|ve insid|
|00001330| 65 20 73 65 74 73 2e 20 | 20 46 6f 72 20 65 78 61 |e sets. | For exa|
|00001340| 6d 70 6c 65 2c 20 5c 63 | 6f 64 65 7b 5b 61 6b 6d |mple, \c|ode{[akm|
|00001350| 5c 24 5d 7d 0a 77 69 6c | 6c 20 6d 61 74 63 68 20 |\$]}.wil|l match |
|00001360| 61 6e 79 20 6f 66 20 74 | 68 65 20 63 68 61 72 61 |any of t|he chara|
|00001370| 63 74 65 72 73 20 27 61 | 27 2c 20 27 6b 27 2c 20 |cters 'a|', 'k', |
|00001380| 27 6d 27 2c 20 6f 72 20 | 27 5c 24 27 3b 20 5c 63 |'m', or |'\$'; \c|
|00001390| 6f 64 65 7b 5b 61 2d 7a | 5d 7d 20 77 69 6c 6c 0a |ode{[a-z|]} will.|
|000013a0| 6d 61 74 63 68 20 61 6e | 79 20 6c 6f 77 65 72 63 |match an|y lowerc|
|000013b0| 61 73 65 20 6c 65 74 74 | 65 72 2e 20 20 0a 0a 49 |ase lett|er. ..I|
|000013c0| 66 20 79 6f 75 20 77 61 | 6e 74 20 74 6f 20 69 6e |f you wa|nt to in|
|000013d0| 63 6c 75 64 65 20 61 20 | 5c 63 6f 64 65 7b 5d 7d |clude a |\code{]}|
|000013e0| 20 69 6e 73 69 64 65 20 | 61 0a 73 65 74 2c 20 69 | inside |a.set, i|
|000013f0| 74 20 6d 75 73 74 20 62 | 65 20 74 68 65 20 66 69 |t must b|e the fi|
|00001400| 72 73 74 20 63 68 61 72 | 61 63 74 65 72 20 6f 66 |rst char|acter of|
|00001410| 20 74 68 65 20 73 65 74 | 3b 20 74 6f 20 69 6e 63 | the set|; to inc|
|00001420| 6c 75 64 65 20 61 20 5c | 63 6f 64 65 7b 2d 7d 2c |lude a \|code{-},|
|00001430| 0a 70 6c 61 63 65 20 69 | 74 20 61 73 20 74 68 65 |.place i|t as the|
|00001440| 20 66 69 72 73 74 20 6f | 72 20 6c 61 73 74 20 63 | first o|r last c|
|00001450| 68 61 72 61 63 74 65 72 | 2e 20 0a 0a 43 68 61 72 |haracter|. ..Char|
|00001460| 61 63 74 65 72 73 20 5c | 65 6d 70 68 7b 6e 6f 74 |acters \|emph{not|
|00001470| 7d 20 77 69 74 68 69 6e | 20 61 20 72 61 6e 67 65 |} within| a range|
|00001480| 20 63 61 6e 20 62 65 20 | 6d 61 74 63 68 65 64 20 | can be |matched |
|00001490| 62 79 20 69 6e 63 6c 75 | 64 69 6e 67 20 61 0a 5c |by inclu|ding a.\|
|000014a0| 63 6f 64 65 7b 5c 5e 7d | 20 61 73 20 74 68 65 20 |code{\^}| as the |
|000014b0| 66 69 72 73 74 20 63 68 | 61 72 61 63 74 65 72 20 |first ch|aracter |
|000014c0| 6f 66 20 74 68 65 20 73 | 65 74 3b 20 5c 63 6f 64 |of the s|et; \cod|
|000014d0| 65 7b 5c 5e 7d 20 65 6c | 73 65 77 68 65 72 65 20 |e{\^} el|sewhere |
|000014e0| 77 69 6c 6c 0a 73 69 6d | 70 6c 79 20 6d 61 74 63 |will.sim|ply matc|
|000014f0| 68 20 74 68 65 20 27 5c | 63 6f 64 65 7b 5c 5e 7d |h the '\|code{\^}|
|00001500| 27 20 63 68 61 72 61 63 | 74 65 72 2e 20 20 0a 5c |' charac|ter. .\|
|00001510| 65 6e 64 7b 69 74 65 6d | 69 7a 65 7d 0a 0a 54 68 |end{item|ize}..Th|
|00001520| 65 20 73 70 65 63 69 61 | 6c 20 73 65 71 75 65 6e |e specia|l sequen|
|00001530| 63 65 73 20 63 6f 6e 73 | 69 73 74 20 6f 66 20 27 |ces cons|ist of '|
|00001540| 5c 63 6f 64 65 7b 5c 65 | 7d 27 20 61 6e 64 20 61 |\code{\e|}' and a|
|00001550| 20 63 68 61 72 61 63 74 | 65 72 0a 66 72 6f 6d 20 | charact|er.from |
|00001560| 74 68 65 20 6c 69 73 74 | 20 62 65 6c 6f 77 2e 20 |the list| below. |
|00001570| 20 49 66 20 74 68 65 20 | 6f 72 64 69 6e 61 72 79 | If the |ordinary|
|00001580| 20 63 68 61 72 61 63 74 | 65 72 20 69 73 20 6e 6f | charact|er is no|
|00001590| 74 20 6f 6e 20 74 68 65 | 20 6c 69 73 74 2c 0a 74 |t on the| list,.t|
|000015a0| 68 65 6e 20 74 68 65 20 | 72 65 73 75 6c 74 69 6e |hen the |resultin|
|000015b0| 67 20 52 45 20 77 69 6c | 6c 20 6d 61 74 63 68 20 |g RE wil|l match |
|000015c0| 74 68 65 20 73 65 63 6f | 6e 64 20 63 68 61 72 61 |the seco|nd chara|
|000015d0| 63 74 65 72 2e 20 20 46 | 6f 72 20 65 78 61 6d 70 |cter. F|or examp|
|000015e0| 6c 65 2c 0a 5c 63 6f 64 | 65 7b 5c 65 5c 24 7d 20 |le,.\cod|e{\e\$} |
|000015f0| 6d 61 74 63 68 65 73 20 | 74 68 65 20 63 68 61 72 |matches |the char|
|00001600| 61 63 74 65 72 20 27 5c | 24 27 2e 20 20 4f 6e 65 |acter '\|$'. One|
|00001610| 73 20 77 68 65 72 65 20 | 74 68 65 20 62 61 63 6b |s where |the back|
|00001620| 73 6c 61 73 68 0a 73 68 | 6f 75 6c 64 20 62 65 20 |slash.sh|ould be |
|00001630| 64 6f 75 62 6c 65 64 20 | 61 72 65 20 69 6e 64 69 |doubled |are indi|
|00001640| 63 61 74 65 64 2e 0a 0a | 5c 62 65 67 69 6e 7b 69 |cated...|\begin{i|
|00001650| 74 65 6d 69 7a 65 7d 0a | 5c 69 74 65 6d 5b 5c 63 |temize}.|\item[\c|
|00001660| 6f 64 65 7b 5c 65 7c 7d | 5d 5c 63 6f 64 65 7b 41 |ode{\e|}|]\code{A|
|00001670| 5c 65 7c 42 7d 2c 20 77 | 68 65 72 65 20 41 20 61 |\e|B}, w|here A a|
|00001680| 6e 64 20 42 20 63 61 6e | 20 62 65 20 61 72 62 69 |nd B can| be arbi|
|00001690| 74 72 61 72 79 20 52 45 | 73 2c 0a 63 72 65 61 74 |trary RE|s,.creat|
|000016a0| 65 73 20 61 20 72 65 67 | 75 6c 61 72 20 65 78 70 |es a reg|ular exp|
|000016b0| 72 65 73 73 69 6f 6e 20 | 74 68 61 74 20 77 69 6c |ression |that wil|
|000016c0| 6c 20 6d 61 74 63 68 20 | 65 69 74 68 65 72 20 41 |l match |either A|
|000016d0| 20 6f 72 20 42 2e 20 20 | 54 68 69 73 20 63 61 6e | or B. |This can|
|000016e0| 0a 62 65 20 75 73 65 64 | 20 69 6e 73 69 64 65 20 |.be used| inside |
|000016f0| 67 72 6f 75 70 73 20 28 | 73 65 65 20 62 65 6c 6f |groups (|see belo|
|00001700| 77 29 20 61 73 20 77 65 | 6c 6c 2e 0a 25 0a 5c 69 |w) as we|ll..%.\i|
|00001710| 74 65 6d 5b 5c 63 6f 64 | 65 7b 5c 65 28 20 5c 65 |tem[\cod|e{\e( \e|
|00001720| 29 7d 5d 7b 49 6e 64 69 | 63 61 74 65 73 20 74 68 |)}]{Indi|cates th|
|00001730| 65 20 73 74 61 72 74 20 | 61 6e 64 20 65 6e 64 20 |e start |and end |
|00001740| 6f 66 20 61 20 67 72 6f | 75 70 3b 20 74 68 65 0a |of a gro|up; the.|
|00001750| 63 6f 6e 74 65 6e 74 73 | 20 6f 66 20 61 20 67 72 |contents| of a gr|
|00001760| 6f 75 70 20 63 61 6e 20 | 62 65 20 6d 61 74 63 68 |oup can |be match|
|00001770| 65 64 20 6c 61 74 65 72 | 20 69 6e 20 74 68 65 20 |ed later| in the |
|00001780| 73 74 72 69 6e 67 20 77 | 69 74 68 20 74 68 65 0a |string w|ith the.|
|00001790| 5c 63 6f 64 65 7b 5c 65 | 20 5c 5b 31 2d 39 5d 7d |\code{\e| \[1-9]}|
|000017a0| 20 73 70 65 63 69 61 6c | 20 73 65 71 75 65 6e 63 | special| sequenc|
|000017b0| 65 2c 20 64 65 73 63 72 | 69 62 65 64 20 6e 65 78 |e, descr|ibed nex|
|000017c0| 74 2e 7d 0a 25 0a 7b 5c | 66 75 6c 6c 6c 69 6e 65 |t.}.%.{\|fullline|
|000017d0| 69 74 65 6d 73 5c 69 74 | 65 6d 5b 5c 63 6f 64 65 |items\it|em[\code|
|000017e0| 7b 5c 65 20 5c 65 20 31 | 2c 20 2e 2e 2e 20 5c 65 |{\e \e 1|, ... \e|
|000017f0| 20 5c 65 20 37 2c 20 5c | 65 20 38 2c 20 5c 65 20 | \e 7, \|e 8, \e |
|00001800| 39 7d 5d 0a 7b 4d 61 74 | 63 68 65 73 20 74 68 65 |9}].{Mat|ches the|
|00001810| 20 63 6f 6e 74 65 6e 74 | 73 20 6f 66 20 74 68 65 | content|s of the|
|00001820| 20 67 72 6f 75 70 20 6f | 66 20 74 68 65 20 73 61 | group o|f the sa|
|00001830| 6d 65 0a 6e 75 6d 62 65 | 72 2e 20 20 46 6f 72 20 |me.numbe|r. For |
|00001840| 65 78 61 6d 70 6c 65 2c | 20 5c 63 6f 64 65 7b 5c |example,| \code{\|
|00001850| 65 20 28 2e 2b 5c 65 20 | 29 20 5c 65 20 5c 65 20 |e (.+\e |) \e \e |
|00001860| 31 7d 20 6d 61 74 63 68 | 65 73 20 27 74 68 65 20 |1} match|es 'the |
|00001870| 74 68 65 27 20 6f 72 0a | 27 35 35 20 35 35 27 2c |the' or.|'55 55',|
|00001880| 20 62 75 74 20 6e 6f 74 | 20 27 74 68 65 20 65 6e | but not| 'the en|
|00001890| 64 27 20 28 6e 6f 74 65 | 20 74 68 65 20 73 70 61 |d' (note| the spa|
|000018a0| 63 65 20 61 66 74 65 72 | 20 74 68 65 20 67 72 6f |ce after| the gro|
|000018b0| 75 70 29 2e 20 20 54 68 | 69 73 0a 73 70 65 63 69 |up). Th|is.speci|
|000018c0| 61 6c 20 73 65 71 75 65 | 6e 63 65 20 63 61 6e 20 |al seque|nce can |
|000018d0| 6f 6e 6c 79 20 62 65 20 | 75 73 65 64 20 74 6f 20 |only be |used to |
|000018e0| 6d 61 74 63 68 20 6f 6e | 65 20 6f 66 20 74 68 65 |match on|e of the|
|000018f0| 20 66 69 72 73 74 20 39 | 20 67 72 6f 75 70 73 3b | first 9| groups;|
|00001900| 0a 67 72 6f 75 70 73 20 | 77 69 74 68 20 68 69 67 |.groups |with hig|
|00001910| 68 65 72 20 6e 75 6d 62 | 65 72 73 20 63 61 6e 20 |her numb|ers can |
|00001920| 62 65 20 6d 61 74 63 68 | 65 64 20 75 73 69 6e 67 |be match|ed using|
|00001930| 20 74 68 65 20 5c 63 6f | 64 65 7b 5c 65 20 76 7d | the \co|de{\e v}|
|00001940| 0a 73 65 71 75 65 6e 63 | 65 2e 20 20 28 5c 63 6f |.sequenc|e. (\co|
|00001950| 64 65 7b 5c 65 20 38 7d | 20 61 6e 64 20 5c 63 6f |de{\e 8}| and \co|
|00001960| 64 65 7b 5c 65 20 39 7d | 20 64 6f 6e 27 74 20 6e |de{\e 9}| don't n|
|00001970| 65 65 64 20 61 20 64 6f | 75 62 6c 65 20 62 61 63 |eed a do|uble bac|
|00001980| 6b 73 6c 61 73 68 0a 62 | 65 63 61 75 73 65 20 74 |kslash.b|ecause t|
|00001990| 68 65 79 20 61 72 65 20 | 6e 6f 74 20 6f 63 74 61 |hey are |not octa|
|000019a0| 6c 20 64 69 67 69 74 73 | 2e 29 7d 7d 0a 25 0a 5c |l digits|.)}}.%.\|
|000019b0| 69 74 65 6d 5b 5c 63 6f | 64 65 7b 5c 65 20 5c 65 |item[\co|de{\e \e|
|000019c0| 20 62 7d 5d 7b 4d 61 74 | 63 68 65 73 20 74 68 65 | b}]{Mat|ches the|
|000019d0| 20 65 6d 70 74 79 20 73 | 74 72 69 6e 67 2c 20 62 | empty s|tring, b|
|000019e0| 75 74 20 6f 6e 6c 79 20 | 61 74 20 74 68 65 0a 62 |ut only |at the.b|
|000019f0| 65 67 69 6e 6e 69 6e 67 | 20 6f 72 20 65 6e 64 20 |eginning| or end |
|00001a00| 6f 66 20 61 20 77 6f 72 | 64 2e 20 20 41 20 77 6f |of a wor|d. A wo|
|00001a10| 72 64 20 69 73 20 64 65 | 66 69 6e 65 64 20 61 73 |rd is de|fined as|
|00001a20| 20 61 20 73 65 71 75 65 | 6e 63 65 20 6f 66 0a 61 | a seque|nce of.a|
|00001a30| 6c 70 68 61 6e 75 6d 65 | 72 69 63 20 63 68 61 72 |lphanume|ric char|
|00001a40| 61 63 74 65 72 73 2c 20 | 73 6f 20 74 68 65 20 65 |acters, |so the e|
|00001a50| 6e 64 20 6f 66 20 61 20 | 77 6f 72 64 20 69 73 20 |nd of a |word is |
|00001a60| 69 6e 64 69 63 61 74 65 | 64 20 62 79 0a 77 68 69 |indicate|d by.whi|
|00001a70| 74 65 73 70 61 63 65 20 | 6f 72 20 61 20 6e 6f 6e |tespace |or a non|
|00001a80| 2d 61 6c 70 68 61 6e 75 | 6d 65 72 69 63 20 63 68 |-alphanu|meric ch|
|00001a90| 61 72 61 63 74 65 72 2e | 7d 0a 25 0a 5c 69 74 65 |aracter.|}.%.\ite|
|00001aa0| 6d 5b 5c 63 6f 64 65 7b | 5c 65 20 42 7d 5d 7b 4d |m[\code{|\e B}]{M|
|00001ab0| 61 74 63 68 65 73 20 74 | 68 65 20 65 6d 70 74 79 |atches t|he empty|
|00001ac0| 20 73 74 72 69 6e 67 2c | 20 62 75 74 20 77 68 65 | string,| but whe|
|00001ad0| 6e 20 69 74 20 69 73 20 | 5c 65 6d 70 68 7b 6e 6f |n it is |\emph{no|
|00001ae0| 74 7d 20 61 74 20 74 68 | 65 0a 62 65 67 69 6e 6e |t} at th|e.beginn|
|00001af0| 69 6e 67 20 6f 72 20 65 | 6e 64 20 6f 66 20 61 20 |ing or e|nd of a |
|00001b00| 77 6f 72 64 2e 7d 20 0a | 25 0a 5c 69 74 65 6d 5b |word.} .|%.\item[|
|00001b10| 5c 63 6f 64 65 7b 5c 65 | 20 76 7d 5d 7b 4d 75 73 |\code{\e| v}]{Mus|
|00001b20| 74 20 62 65 20 66 6f 6c | 6c 6f 77 65 64 20 62 79 |t be fol|lowed by|
|00001b30| 20 61 20 74 77 6f 20 64 | 69 67 69 74 20 64 65 63 | a two d|igit dec|
|00001b40| 69 6d 61 6c 20 6e 75 6d | 62 65 72 2c 20 61 6e 64 |imal num|ber, and|
|00001b50| 0a 6d 61 74 63 68 65 73 | 20 74 68 65 20 63 6f 6e |.matches| the con|
|00001b60| 74 65 6e 74 73 20 6f 66 | 20 74 68 65 20 67 72 6f |tents of| the gro|
|00001b70| 75 70 20 6f 66 20 74 68 | 65 20 73 61 6d 65 20 6e |up of th|e same n|
|00001b80| 75 6d 62 65 72 2e 20 20 | 54 68 65 20 67 72 6f 75 |umber. |The grou|
|00001b90| 70 20 6e 75 6d 62 65 72 | 20 6d 75 73 74 20 62 65 |p number| must be|
|00001ba0| 20 62 65 74 77 65 65 6e | 20 31 20 61 6e 64 20 39 | between| 1 and 9|
|00001bb0| 39 2c 20 69 6e 63 6c 75 | 73 69 76 65 2e 7d 0a 25 |9, inclu|sive.}.%|
|00001bc0| 0a 5c 69 74 65 6d 5b 5c | 63 6f 64 65 7b 5c 65 20 |.\item[\|code{\e |
|00001bd0| 77 7d 5d 4d 61 74 63 68 | 65 73 20 61 6e 79 20 61 |w}]Match|es any a|
|00001be0| 6c 70 68 61 6e 75 6d 65 | 72 69 63 20 63 68 61 72 |lphanume|ric char|
|00001bf0| 61 63 74 65 72 3b 20 74 | 68 69 73 20 69 73 0a 65 |acter; t|his is.e|
|00001c00| 71 75 69 76 61 6c 65 6e | 74 20 74 6f 20 74 68 65 |quivalen|t to the|
|00001c10| 20 73 65 74 20 5c 63 6f | 64 65 7b 5b 61 2d 7a 41 | set \co|de{[a-zA|
|00001c20| 2d 5a 30 2d 39 5d 7d 2e | 0a 25 0a 5c 69 74 65 6d |-Z0-9]}.|.%.\item|
|00001c30| 5b 5c 63 6f 64 65 7b 5c | 65 20 57 7d 5d 7b 4d 61 |[\code{\|e W}]{Ma|
|00001c40| 74 63 68 65 73 20 61 6e | 79 20 6e 6f 6e 2d 61 6c |tches an|y non-al|
|00001c50| 70 68 61 6e 75 6d 65 72 | 69 63 20 63 68 61 72 61 |phanumer|ic chara|
|00001c60| 63 74 65 72 3b 20 74 68 | 69 73 20 69 73 0a 65 71 |cter; th|is is.eq|
|00001c70| 75 69 76 61 6c 65 6e 74 | 20 74 6f 20 74 68 65 20 |uivalent| to the |
|00001c80| 73 65 74 20 5c 63 6f 64 | 65 7b 5b 5c 5e 61 2d 7a |set \cod|e{[\^a-z|
|00001c90| 41 2d 5a 30 2d 39 5d 7d | 2e 7d 20 0a 5c 69 74 65 |A-Z0-9]}|.} .\ite|
|00001ca0| 6d 5b 5c 63 6f 64 65 7b | 5c 65 20 3c 7d 5d 7b 4d |m[\code{|\e <}]{M|
|00001cb0| 61 74 63 68 65 73 20 74 | 68 65 20 65 6d 70 74 79 |atches t|he empty|
|00001cc0| 20 73 74 72 69 6e 67 2c | 20 62 75 74 20 6f 6e 6c | string,| but onl|
|00001cd0| 79 20 61 74 20 74 68 65 | 20 62 65 67 69 6e 6e 69 |y at the| beginni|
|00001ce0| 6e 67 20 6f 66 20 61 0a | 77 6f 72 64 2e 20 20 41 |ng of a.|word. A|
|00001cf0| 20 77 6f 72 64 20 69 73 | 20 64 65 66 69 6e 65 64 | word is| defined|
|00001d00| 20 61 73 20 61 20 73 65 | 71 75 65 6e 63 65 20 6f | as a se|quence o|
|00001d10| 66 20 61 6c 70 68 61 6e | 75 6d 65 72 69 63 20 63 |f alphan|umeric c|
|00001d20| 68 61 72 61 63 74 65 72 | 73 2c 20 73 6f 0a 74 68 |haracter|s, so.th|
|00001d30| 65 20 65 6e 64 20 6f 66 | 20 61 20 77 6f 72 64 20 |e end of| a word |
|00001d40| 69 73 20 69 6e 64 69 63 | 61 74 65 64 20 62 79 20 |is indic|ated by |
|00001d50| 77 68 69 74 65 73 70 61 | 63 65 20 6f 72 20 61 20 |whitespa|ce or a |
|00001d60| 6e 6f 6e 2d 61 6c 70 68 | 61 6e 75 6d 65 72 69 63 |non-alph|anumeric|
|00001d70| 20 0a 63 68 61 72 61 63 | 74 65 72 2e 7d 0a 5c 69 | .charac|ter.}.\i|
|00001d80| 74 65 6d 5b 5c 63 6f 64 | 65 7b 5c 65 20 3e 7d 5d |tem[\cod|e{\e >}]|
|00001d90| 7b 4d 61 74 63 68 65 73 | 20 74 68 65 20 65 6d 70 |{Matches| the emp|
|00001da0| 74 79 20 73 74 72 69 6e | 67 2c 20 62 75 74 20 6f |ty strin|g, but o|
|00001db0| 6e 6c 79 20 61 74 20 74 | 68 65 20 65 6e 64 20 6f |nly at t|he end o|
|00001dc0| 66 20 61 0a 77 6f 72 64 | 2e 7d 0a 0a 5c 69 74 65 |f a.word|.}..\ite|
|00001dd0| 6d 5b 5c 63 6f 64 65 7b | 5c 65 20 5c 65 20 5c 65 |m[\code{|\e \e \e|
|00001de0| 20 5c 65 7d 5d 7b 4d 61 | 74 63 68 65 73 20 61 20 | \e}]{Ma|tches a |
|00001df0| 6c 69 74 65 72 61 6c 20 | 62 61 63 6b 73 6c 61 73 |literal |backslas|
|00001e00| 68 2e 7d 0a 0a 25 20 49 | 6e 20 45 6d 61 63 73 2c |h.}..% I|n Emacs,|
|00001e10| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 74 | the fol|lowing t|
|00001e20| 77 6f 20 61 72 65 20 73 | 74 61 72 74 20 6f 66 20 |wo are s|tart of |
|00001e30| 62 75 66 66 65 72 2f 65 | 6e 64 20 6f 66 20 62 75 |buffer/e|nd of bu|
|00001e40| 66 66 65 72 2e 20 20 49 | 6e 0a 25 20 50 79 74 68 |ffer. I|n.% Pyth|
|00001e50| 6f 6e 20 74 68 65 79 20 | 73 65 65 6d 20 74 6f 20 |on they |seem to |
|00001e60| 62 65 20 73 79 6e 6f 6e | 79 6d 73 20 66 6f 72 20 |be synon|yms for |
|00001e70| 5e 24 2e 0a 5c 69 74 65 | 6d 5b 5c 63 6f 64 65 7b |^$..\ite|m[\code{|
|00001e80| 5c 65 20 60 7d 5d 7b 4c | 69 6b 65 20 5c 63 6f 64 |\e `}]{L|ike \cod|
|00001e90| 65 7b 5c 5e 7d 2c 20 74 | 68 69 73 20 6f 6e 6c 79 |e{\^}, t|his only|
|00001ea0| 20 6d 61 74 63 68 65 73 | 20 61 74 20 74 68 65 20 | matches| at the |
|00001eb0| 73 74 61 72 74 20 6f 66 | 20 74 68 65 0a 73 74 72 |start of| the.str|
|00001ec0| 69 6e 67 2e 7d 0a 5c 69 | 74 65 6d 5b 5c 63 6f 64 |ing.}.\i|tem[\cod|
|00001ed0| 65 7b 5c 65 20 5c 65 20 | 27 7d 5d 20 4c 69 6b 65 |e{\e \e |'}] Like|
|00001ee0| 20 5c 63 6f 64 65 7b 5c | 24 7d 2c 20 74 68 69 73 | \code{\|$}, this|
|00001ef0| 20 6f 6e 6c 79 20 6d 61 | 74 63 68 65 73 20 61 74 | only ma|tches at|
|00001f00| 20 74 68 65 20 65 6e 64 | 20 6f 66 20 74 68 65 0a | the end| of the.|
|00001f10| 73 74 72 69 6e 67 2e 0a | 25 20 65 6e 64 20 6f 66 |string..|% end of|
|00001f20| 20 62 75 66 66 65 72 0a | 5c 65 6e 64 7b 69 74 65 | buffer.|\end{ite|
|00001f30| 6d 69 7a 65 7d 0a 0a 5c | 73 75 62 73 65 63 74 69 |mize}..\|subsecti|
|00001f40| 6f 6e 7b 4d 6f 64 75 6c | 65 20 43 6f 6e 74 65 6e |on{Modul|e Conten|
|00001f50| 74 73 7d 0a 0a 54 68 65 | 20 6d 6f 64 75 6c 65 20 |ts}..The| module |
|00001f60| 64 65 66 69 6e 65 73 20 | 74 68 65 73 65 20 66 75 |defines |these fu|
|00001f70| 6e 63 74 69 6f 6e 73 2c | 20 61 6e 64 20 61 6e 20 |nctions,| and an |
|00001f80| 65 78 63 65 70 74 69 6f | 6e 3a 0a 0a 5c 72 65 6e |exceptio|n:..\ren|
|00001f90| 65 77 63 6f 6d 6d 61 6e | 64 7b 5c 69 6e 64 65 78 |ewcomman|d{\index|
|00001fa0| 73 75 62 69 74 65 6d 7d | 7b 28 69 6e 20 6d 6f 64 |subitem}|{(in mod|
|00001fb0| 75 6c 65 20 72 65 67 65 | 78 29 7d 0a 0a 5c 62 65 |ule rege|x)}..\be|
|00001fc0| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 6d 61 |gin{func|desc}{ma|
|00001fd0| 74 63 68 7d 7b 70 61 74 | 74 65 72 6e 5c 2c 20 73 |tch}{pat|tern\, s|
|00001fe0| 74 72 69 6e 67 7d 0a 20 | 20 52 65 74 75 72 6e 20 |tring}. | Return |
|00001ff0| 68 6f 77 20 6d 61 6e 79 | 20 63 68 61 72 61 63 74 |how many| charact|
|00002000| 65 72 73 20 61 74 20 74 | 68 65 20 62 65 67 69 6e |ers at t|he begin|
|00002010| 6e 69 6e 67 20 6f 66 20 | 5c 76 61 72 7b 73 74 72 |ning of |\var{str|
|00002020| 69 6e 67 7d 20 6d 61 74 | 63 68 0a 20 20 74 68 65 |ing} mat|ch. the|
|00002030| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00002040| 69 6f 6e 20 5c 76 61 72 | 7b 70 61 74 74 65 72 6e |ion \var|{pattern|
|00002050| 7d 2e 20 20 52 65 74 75 | 72 6e 20 5c 63 6f 64 65 |}. Retu|rn \code|
|00002060| 7b 2d 31 7d 20 69 66 20 | 74 68 65 0a 20 20 73 74 |{-1} if |the. st|
|00002070| 72 69 6e 67 20 64 6f 65 | 73 20 6e 6f 74 20 6d 61 |ring doe|s not ma|
|00002080| 74 63 68 20 74 68 65 20 | 70 61 74 74 65 72 6e 20 |tch the |pattern |
|00002090| 28 74 68 69 73 20 69 73 | 20 64 69 66 66 65 72 65 |(this is| differe|
|000020a0| 6e 74 20 66 72 6f 6d 20 | 61 0a 20 20 7a 65 72 6f |nt from |a. zero|
|000020b0| 2d 6c 65 6e 67 74 68 20 | 6d 61 74 63 68 21 29 2e |-length |match!).|
|000020c0| 0a 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0a |.\end{fu|ncdesc}.|
|000020d0| 0a 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|000020e0| 7d 7b 73 65 61 72 63 68 | 7d 7b 70 61 74 74 65 72 |}{search|}{patter|
|000020f0| 6e 5c 2c 20 73 74 72 69 | 6e 67 7d 0a 20 20 52 65 |n\, stri|ng}. Re|
|00002100| 74 75 72 6e 20 74 68 65 | 20 66 69 72 73 74 20 70 |turn the| first p|
|00002110| 6f 73 69 74 69 6f 6e 20 | 69 6e 20 5c 76 61 72 7b |osition |in \var{|
|00002120| 73 74 72 69 6e 67 7d 20 | 74 68 61 74 20 6d 61 74 |string} |that mat|
|00002130| 63 68 65 73 20 74 68 65 | 20 72 65 67 75 6c 61 72 |ches the| regular|
|00002140| 0a 20 20 65 78 70 72 65 | 73 73 69 6f 6e 20 5c 76 |. expre|ssion \v|
|00002150| 61 72 7b 70 61 74 74 65 | 72 6e 7d 2e 20 20 52 65 |ar{patte|rn}. Re|
|00002160| 74 75 72 6e 20 5c 63 6f | 64 65 7b 2d 31 7d 20 69 |turn \co|de{-1} i|
|00002170| 66 20 6e 6f 20 70 6f 73 | 69 74 69 6f 6e 20 69 6e |f no pos|ition in|
|00002180| 20 74 68 65 20 73 74 72 | 69 6e 67 0a 20 20 6d 61 | the str|ing. ma|
|00002190| 74 63 68 65 73 20 74 68 | 65 20 70 61 74 74 65 72 |tches th|e patter|
|000021a0| 6e 20 28 74 68 69 73 20 | 69 73 20 64 69 66 66 65 |n (this |is diffe|
|000021b0| 72 65 6e 74 20 66 72 6f | 6d 20 61 20 7a 65 72 6f |rent fro|m a zero|
|000021c0| 2d 6c 65 6e 67 74 68 20 | 6d 61 74 63 68 0a 20 20 |-length |match. |
|000021d0| 61 6e 79 77 68 65 72 65 | 21 29 2e 0a 5c 65 6e 64 |anywhere|!)..\end|
|000021e0| 7b 66 75 6e 63 64 65 73 | 63 7d 0a 0a 5c 62 65 67 |{funcdes|c}..\beg|
|000021f0| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 63 6f 6d |in{funcd|esc}{com|
|00002200| 70 69 6c 65 7d 7b 70 61 | 74 74 65 72 6e 5c 6f 70 |pile}{pa|ttern\op|
|00002210| 74 69 6f 6e 61 6c 7b 5c | 2c 20 74 72 61 6e 73 6c |tional{\|, transl|
|00002220| 61 74 65 7d 7d 0a 20 20 | 43 6f 6d 70 69 6c 65 20 |ate}}. |Compile |
|00002230| 61 20 72 65 67 75 6c 61 | 72 20 65 78 70 72 65 73 |a regula|r expres|
|00002240| 73 69 6f 6e 20 70 61 74 | 74 65 72 6e 20 69 6e 74 |sion pat|tern int|
|00002250| 6f 20 61 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 |o a regu|lar expr|
|00002260| 65 73 73 69 6f 6e 0a 20 | 20 6f 62 6a 65 63 74 2c |ession. | object,|
|00002270| 20 77 68 69 63 68 20 63 | 61 6e 20 62 65 20 75 73 | which c|an be us|
|00002280| 65 64 20 66 6f 72 20 6d | 61 74 63 68 69 6e 67 20 |ed for m|atching |
|00002290| 75 73 69 6e 67 20 69 74 | 73 20 5c 63 6f 64 65 7b |using it|s \code{|
|000022a0| 6d 61 74 63 68 7d 20 61 | 6e 64 0a 20 20 5c 63 6f |match} a|nd. \co|
|000022b0| 64 65 7b 73 65 61 72 63 | 68 7d 20 6d 65 74 68 6f |de{searc|h} metho|
|000022c0| 64 73 2c 20 64 65 73 63 | 72 69 62 65 64 20 62 65 |ds, desc|ribed be|
|000022d0| 6c 6f 77 2e 20 20 54 68 | 65 20 6f 70 74 69 6f 6e |low. Th|e option|
|000022e0| 61 6c 20 61 72 67 75 6d | 65 6e 74 0a 20 20 5c 76 |al argum|ent. \v|
|000022f0| 61 72 7b 74 72 61 6e 73 | 6c 61 74 65 7d 2c 20 69 |ar{trans|late}, i|
|00002300| 66 20 70 72 65 73 65 6e | 74 2c 20 6d 75 73 74 20 |f presen|t, must |
|00002310| 62 65 20 61 20 32 35 36 | 2d 63 68 61 72 61 63 74 |be a 256|-charact|
|00002320| 65 72 20 73 74 72 69 6e | 67 0a 20 20 69 6e 64 69 |er strin|g. indi|
|00002330| 63 61 74 69 6e 67 20 68 | 6f 77 20 63 68 61 72 61 |cating h|ow chara|
|00002340| 63 74 65 72 73 20 28 62 | 6f 74 68 20 6f 66 20 74 |cters (b|oth of t|
|00002350| 68 65 20 70 61 74 74 65 | 72 6e 20 61 6e 64 20 6f |he patte|rn and o|
|00002360| 66 20 74 68 65 20 73 74 | 72 69 6e 67 73 20 74 6f |f the st|rings to|
|00002370| 0a 20 20 62 65 20 6d 61 | 74 63 68 65 64 29 20 61 |. be ma|tched) a|
|00002380| 72 65 20 74 72 61 6e 73 | 6c 61 74 65 64 20 62 65 |re trans|lated be|
|00002390| 66 6f 72 65 20 63 6f 6d | 70 61 72 69 6e 67 20 74 |fore com|paring t|
|000023a0| 68 65 6d 3b 20 74 68 65 | 20 5c 63 6f 64 65 7b 69 |hem; the| \code{i|
|000023b0| 7d 2d 74 68 0a 20 20 65 | 6c 65 6d 65 6e 74 20 6f |}-th. e|lement o|
|000023c0| 66 20 74 68 65 20 73 74 | 72 69 6e 67 20 67 69 76 |f the st|ring giv|
|000023d0| 65 73 20 74 68 65 20 74 | 72 61 6e 73 6c 61 74 69 |es the t|ranslati|
|000023e0| 6f 6e 20 66 6f 72 20 74 | 68 65 20 63 68 61 72 61 |on for t|he chara|
|000023f0| 63 74 65 72 20 77 69 74 | 68 0a 20 20 5c 41 53 43 |cter wit|h. \ASC|
|00002400| 49 49 7b 7d 20 63 6f 64 | 65 20 5c 63 6f 64 65 7b |II{} cod|e \code{|
|00002410| 69 7d 2e 20 20 54 68 69 | 73 20 63 61 6e 20 62 65 |i}. Thi|s can be|
|00002420| 20 75 73 65 64 20 74 6f | 20 69 6d 70 6c 65 6d 65 | used to| impleme|
|00002430| 6e 74 0a 20 20 63 61 73 | 65 2d 69 6e 73 65 6e 73 |nt. cas|e-insens|
|00002440| 69 74 69 76 65 20 6d 61 | 74 63 68 69 6e 67 3b 20 |itive ma|tching; |
|00002450| 73 65 65 20 74 68 65 20 | 5c 63 6f 64 65 7b 63 61 |see the |\code{ca|
|00002460| 73 65 66 6f 6c 64 7d 20 | 64 61 74 61 20 69 74 65 |sefold} |data ite|
|00002470| 6d 20 62 65 6c 6f 77 2e | 0a 0a 20 20 54 68 65 20 |m below.|.. The |
|00002480| 73 65 71 75 65 6e 63 65 | 0a 0a 5c 62 63 6f 64 65 |sequence|..\bcode|
|00002490| 5c 62 65 67 69 6e 7b 76 | 65 72 62 61 74 69 6d 7d |\begin{v|erbatim}|
|000024a0| 0a 70 72 6f 67 20 3d 20 | 72 65 67 65 78 2e 63 6f |.prog = |regex.co|
|000024b0| 6d 70 69 6c 65 28 70 61 | 74 29 0a 72 65 73 75 6c |mpile(pa|t).resul|
|000024c0| 74 20 3d 20 70 72 6f 67 | 2e 6d 61 74 63 68 28 73 |t = prog|.match(s|
|000024d0| 74 72 29 0a 5c 65 6e 64 | 7b 76 65 72 62 61 74 69 |tr).\end|{verbati|
|000024e0| 6d 7d 5c 65 63 6f 64 65 | 0a 0a 69 73 20 65 71 75 |m}\ecode|..is equ|
|000024f0| 69 76 61 6c 65 6e 74 20 | 74 6f 0a 0a 5c 62 63 6f |ivalent |to..\bco|
|00002500| 64 65 5c 62 65 67 69 6e | 7b 76 65 72 62 61 74 69 |de\begin|{verbati|
|00002510| 6d 7d 0a 72 65 73 75 6c | 74 20 3d 20 72 65 67 65 |m}.resul|t = rege|
|00002520| 78 2e 6d 61 74 63 68 28 | 70 61 74 2c 20 73 74 72 |x.match(|pat, str|
|00002530| 29 0a 5c 65 6e 64 7b 76 | 65 72 62 61 74 69 6d 7d |).\end{v|erbatim}|
|00002540| 5c 65 63 6f 64 65 0a 0a | 62 75 74 20 74 68 65 20 |\ecode..|but the |
|00002550| 76 65 72 73 69 6f 6e 20 | 75 73 69 6e 67 20 5c 63 |version |using \c|
|00002560| 6f 64 65 7b 63 6f 6d 70 | 69 6c 65 28 29 7d 20 69 |ode{comp|ile()} i|
|00002570| 73 20 6d 6f 72 65 20 65 | 66 66 69 63 69 65 6e 74 |s more e|fficient|
|00002580| 20 77 68 65 6e 20 6d 75 | 6c 74 69 70 6c 65 0a 72 | when mu|ltiple.r|
|00002590| 65 67 75 6c 61 72 20 65 | 78 70 72 65 73 73 69 6f |egular e|xpressio|
|000025a0| 6e 73 20 61 72 65 20 75 | 73 65 64 20 63 6f 6e 63 |ns are u|sed conc|
|000025b0| 75 72 72 65 6e 74 6c 79 | 20 69 6e 20 61 20 73 69 |urrently| in a si|
|000025c0| 6e 67 6c 65 20 70 72 6f | 67 72 61 6d 2e 20 20 28 |ngle pro|gram. (|
|000025d0| 54 68 65 0a 63 6f 6d 70 | 69 6c 65 64 20 76 65 72 |The.comp|iled ver|
|000025e0| 73 69 6f 6e 20 6f 66 20 | 74 68 65 20 6c 61 73 74 |sion of |the last|
|000025f0| 20 70 61 74 74 65 72 6e | 20 70 61 73 73 65 64 20 | pattern| passed |
|00002600| 74 6f 20 5c 63 6f 64 65 | 7b 72 65 67 65 78 2e 6d |to \code|{regex.m|
|00002610| 61 74 63 68 28 29 7d 20 | 6f 72 0a 5c 63 6f 64 65 |atch()} |or.\code|
|00002620| 7b 72 65 67 65 78 2e 73 | 65 61 72 63 68 28 29 7d |{regex.s|earch()}|
|00002630| 20 69 73 20 63 61 63 68 | 65 64 2c 20 73 6f 20 70 | is cach|ed, so p|
|00002640| 72 6f 67 72 61 6d 73 20 | 74 68 61 74 20 75 73 65 |rograms |that use|
|00002650| 20 6f 6e 6c 79 20 61 20 | 73 69 6e 67 6c 65 0a 72 | only a |single.r|
|00002660| 65 67 75 6c 61 72 20 65 | 78 70 72 65 73 73 69 6f |egular e|xpressio|
|00002670| 6e 20 61 74 20 61 20 74 | 69 6d 65 20 6e 65 65 64 |n at a t|ime need|
|00002680| 6e 27 74 20 77 6f 72 72 | 79 20 61 62 6f 75 74 20 |n't worr|y about |
|00002690| 63 6f 6d 70 69 6c 69 6e | 67 20 72 65 67 75 6c 61 |compilin|g regula|
|000026a0| 72 0a 65 78 70 72 65 73 | 73 69 6f 6e 73 2e 29 0a |r.expres|sions.).|
|000026b0| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0a 0a |\end{fun|cdesc}..|
|000026c0| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|000026d0| 7b 73 65 74 5f 73 79 6e | 74 61 78 7d 7b 66 6c 61 |{set_syn|tax}{fla|
|000026e0| 67 73 7d 0a 20 20 53 65 | 74 20 74 68 65 20 73 79 |gs}. Se|t the sy|
|000026f0| 6e 74 61 78 20 74 6f 20 | 62 65 20 75 73 65 64 20 |ntax to |be used |
|00002700| 62 79 20 66 75 74 75 72 | 65 20 63 61 6c 6c 73 20 |by futur|e calls |
|00002710| 74 6f 20 5c 63 6f 64 65 | 7b 63 6f 6d 70 69 6c 65 |to \code|{compile|
|00002720| 7d 2c 0a 20 20 5c 63 6f | 64 65 7b 6d 61 74 63 68 |},. \co|de{match|
|00002730| 7d 20 61 6e 64 20 5c 63 | 6f 64 65 7b 73 65 61 72 |} and \c|ode{sear|
|00002740| 63 68 7d 2e 20 20 28 41 | 6c 72 65 61 64 79 20 63 |ch}. (A|lready c|
|00002750| 6f 6d 70 69 6c 65 64 20 | 65 78 70 72 65 73 73 69 |ompiled |expressi|
|00002760| 6f 6e 20 6f 62 6a 65 63 | 74 73 0a 20 20 61 72 65 |on objec|ts. are|
|00002770| 20 6e 6f 74 20 61 66 66 | 65 63 74 65 64 2e 29 20 | not aff|ected.) |
|00002780| 20 54 68 65 20 61 72 67 | 75 6d 65 6e 74 20 69 73 | The arg|ument is|
|00002790| 20 61 6e 20 69 6e 74 65 | 67 65 72 20 77 68 69 63 | an inte|ger whic|
|000027a0| 68 20 69 73 20 74 68 65 | 20 4f 52 20 6f 66 0a 20 |h is the| OR of. |
|000027b0| 20 73 65 76 65 72 61 6c | 20 66 6c 61 67 20 62 69 | several| flag bi|
|000027c0| 74 73 2e 20 20 54 68 65 | 20 72 65 74 75 72 6e 20 |ts. The| return |
|000027d0| 76 61 6c 75 65 20 69 73 | 20 74 68 65 20 70 72 65 |value is| the pre|
|000027e0| 76 69 6f 75 73 20 76 61 | 6c 75 65 20 6f 66 0a 20 |vious va|lue of. |
|000027f0| 20 74 68 65 20 73 79 6e | 74 61 78 20 66 6c 61 67 | the syn|tax flag|
|00002800| 73 2e 20 20 4e 61 6d 65 | 73 20 66 6f 72 20 74 68 |s. Name|s for th|
|00002810| 65 20 66 6c 61 67 73 20 | 61 72 65 20 64 65 66 69 |e flags |are defi|
|00002820| 6e 65 64 20 69 6e 20 74 | 68 65 20 73 74 61 6e 64 |ned in t|he stand|
|00002830| 61 72 64 0a 20 20 6d 6f | 64 75 6c 65 20 5c 63 6f |ard. mo|dule \co|
|00002840| 64 65 7b 72 65 67 65 78 | 5f 73 79 6e 74 61 78 7d |de{regex|_syntax}|
|00002850| 3b 20 72 65 61 64 20 74 | 68 65 20 66 69 6c 65 20 |; read t|he file |
|00002860| 5c 66 69 6c 65 7b 72 65 | 67 65 78 5f 73 79 6e 74 |\file{re|gex_synt|
|00002870| 61 78 2e 70 79 7d 20 66 | 6f 72 0a 20 20 6d 6f 72 |ax.py} f|or. mor|
|00002880| 65 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 2e 0a 5c |e inform|ation..\|
|00002890| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0a 0a 5c |end{func|desc}..\|
|000028a0| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|000028b0| 73 79 6d 63 6f 6d 70 7d | 7b 70 61 74 74 65 72 6e |symcomp}|{pattern|
|000028c0| 5c 6f 70 74 69 6f 6e 61 | 6c 7b 5c 2c 20 74 72 61 |\optiona|l{\, tra|
|000028d0| 6e 73 6c 61 74 65 7d 7d | 0a 54 68 69 73 20 69 73 |nslate}}|.This is|
|000028e0| 20 6c 69 6b 65 20 5c 63 | 6f 64 65 7b 63 6f 6d 70 | like \c|ode{comp|
|000028f0| 69 6c 65 7d 2c 20 62 75 | 74 20 73 75 70 70 6f 72 |ile}, bu|t suppor|
|00002900| 74 73 20 73 79 6d 62 6f | 6c 69 63 20 67 72 6f 75 |ts symbo|lic grou|
|00002910| 70 20 6e 61 6d 65 73 3a | 20 69 66 20 61 0a 70 61 |p names:| if a.pa|
|00002920| 72 65 6e 74 68 65 73 69 | 73 2d 65 6e 63 6c 6f 73 |renthesi|s-enclos|
|00002930| 65 64 20 67 72 6f 75 70 | 20 62 65 67 69 6e 73 20 |ed group| begins |
|00002940| 77 69 74 68 20 61 20 67 | 72 6f 75 70 20 6e 61 6d |with a g|roup nam|
|00002950| 65 20 69 6e 20 61 6e 67 | 75 6c 61 72 0a 62 72 61 |e in ang|ular.bra|
|00002960| 63 6b 65 74 73 2c 20 65 | 2e 67 2e 20 5c 63 6f 64 |ckets, e|.g. \cod|
|00002970| 65 7b 27 5c 65 28 3c 69 | 64 3e 5b 61 2d 7a 5d 5b |e{'\e(<i|d>[a-z][|
|00002980| 61 2d 7a 30 2d 39 5d 2a | 5c 65 29 27 7d 2c 20 74 |a-z0-9]*|\e)'}, t|
|00002990| 68 65 20 67 72 6f 75 70 | 20 63 61 6e 0a 62 65 20 |he group| can.be |
|000029a0| 72 65 66 65 72 65 6e 63 | 65 64 20 62 79 20 69 74 |referenc|ed by it|
|000029b0| 73 20 6e 61 6d 65 20 69 | 6e 20 61 72 67 75 6d 65 |s name i|n argume|
|000029c0| 6e 74 73 20 74 6f 20 74 | 68 65 20 5c 63 6f 64 65 |nts to t|he \code|
|000029d0| 7b 67 72 6f 75 70 7d 20 | 6d 65 74 68 6f 64 20 6f |{group} |method o|
|000029e0| 66 0a 74 68 65 20 72 65 | 73 75 6c 74 69 6e 67 20 |f.the re|sulting |
|000029f0| 63 6f 6d 70 69 6c 65 64 | 20 72 65 67 75 6c 61 72 |compiled| regular|
|00002a00| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 6f 62 6a 65 | express|ion obje|
|00002a10| 63 74 2c 20 6c 69 6b 65 | 20 74 68 69 73 3a 0a 5c |ct, like| this:.\|
|00002a20| 63 6f 64 65 7b 70 2e 67 | 72 6f 75 70 28 27 69 64 |code{p.g|roup('id|
|00002a30| 27 29 7d 2e 20 20 47 72 | 6f 75 70 20 6e 61 6d 65 |')}. Gr|oup name|
|00002a40| 73 20 6d 61 79 20 63 6f | 6e 74 61 69 6e 20 61 6c |s may co|ntain al|
|00002a50| 70 68 61 6e 75 6d 65 72 | 69 63 20 63 68 61 72 61 |phanumer|ic chara|
|00002a60| 63 74 65 72 73 0a 61 6e | 64 20 5c 63 6f 64 65 7b |cters.an|d \code{|
|00002a70| 27 5f 27 7d 20 6f 6e 6c | 79 2e 0a 5c 65 6e 64 7b |'_'} onl|y..\end{|
|00002a80| 66 75 6e 63 64 65 73 63 | 7d 0a 0a 5c 62 65 67 69 |funcdesc|}..\begi|
|00002a90| 6e 7b 65 78 63 64 65 73 | 63 7d 7b 65 72 72 6f 72 |n{excdes|c}{error|
|00002aa0| 7d 0a 20 20 45 78 63 65 | 70 74 69 6f 6e 20 72 61 |}. Exce|ption ra|
|00002ab0| 69 73 65 64 20 77 68 65 | 6e 20 61 20 73 74 72 69 |ised whe|n a stri|
|00002ac0| 6e 67 20 70 61 73 73 65 | 64 20 74 6f 20 6f 6e 65 |ng passe|d to one|
|00002ad0| 20 6f 66 20 74 68 65 20 | 66 75 6e 63 74 69 6f 6e | of the |function|
|00002ae0| 73 20 68 65 72 65 0a 20 | 20 69 73 20 6e 6f 74 20 |s here. | is not |
|00002af0| 61 20 76 61 6c 69 64 20 | 72 65 67 75 6c 61 72 20 |a valid |regular |
|00002b00| 65 78 70 72 65 73 73 69 | 6f 6e 20 28 65 2e 67 2e |expressi|on (e.g.|
|00002b10| 2c 20 75 6e 6d 61 74 63 | 68 65 64 20 70 61 72 65 |, unmatc|hed pare|
|00002b20| 6e 74 68 65 73 65 73 29 | 20 6f 72 0a 20 20 77 68 |ntheses)| or. wh|
|00002b30| 65 6e 20 73 6f 6d 65 20 | 6f 74 68 65 72 20 65 72 |en some |other er|
|00002b40| 72 6f 72 20 6f 63 63 75 | 72 73 20 64 75 72 69 6e |ror occu|rs durin|
|00002b50| 67 20 63 6f 6d 70 69 6c | 61 74 69 6f 6e 20 6f 72 |g compil|ation or|
|00002b60| 20 6d 61 74 63 68 69 6e | 67 2e 20 20 28 49 74 20 | matchin|g. (It |
|00002b70| 69 73 0a 20 20 6e 65 76 | 65 72 20 61 6e 20 65 72 |is. nev|er an er|
|00002b80| 72 6f 72 20 69 66 20 61 | 20 73 74 72 69 6e 67 20 |ror if a| string |
|00002b90| 63 6f 6e 74 61 69 6e 73 | 20 6e 6f 20 6d 61 74 63 |contains| no matc|
|00002ba0| 68 20 66 6f 72 20 61 20 | 70 61 74 74 65 72 6e 2e |h for a |pattern.|
|00002bb0| 29 0a 5c 65 6e 64 7b 65 | 78 63 64 65 73 63 7d 0a |).\end{e|xcdesc}.|
|00002bc0| 0a 5c 62 65 67 69 6e 7b | 64 61 74 61 64 65 73 63 |.\begin{|datadesc|
|00002bd0| 7d 7b 63 61 73 65 66 6f | 6c 64 7d 0a 41 20 73 74 |}{casefo|ld}.A st|
|00002be0| 72 69 6e 67 20 73 75 69 | 74 61 62 6c 65 20 74 6f |ring sui|table to|
|00002bf0| 20 70 61 73 73 20 61 73 | 20 5c 76 61 72 7b 74 72 | pass as| \var{tr|
|00002c00| 61 6e 73 6c 61 74 65 7d | 20 61 72 67 75 6d 65 6e |anslate}| argumen|
|00002c10| 74 20 74 6f 0a 5c 63 6f | 64 65 7b 63 6f 6d 70 69 |t to.\co|de{compi|
|00002c20| 6c 65 7d 20 74 6f 20 6d | 61 70 20 61 6c 6c 20 75 |le} to m|ap all u|
|00002c30| 70 70 65 72 20 63 61 73 | 65 20 63 68 61 72 61 63 |pper cas|e charac|
|00002c40| 74 65 72 73 20 74 6f 20 | 74 68 65 69 72 20 6c 6f |ters to |their lo|
|00002c50| 77 65 72 63 61 73 65 0a | 65 71 75 69 76 61 6c 65 |wercase.|equivale|
|00002c60| 6e 74 73 2e 0a 5c 65 6e | 64 7b 64 61 74 61 64 65 |nts..\en|d{datade|
|00002c70| 73 63 7d 0a 0a 5c 6e 6f | 69 6e 64 65 6e 74 0a 43 |sc}..\no|indent.C|
|00002c80| 6f 6d 70 69 6c 65 64 20 | 72 65 67 75 6c 61 72 20 |ompiled |regular |
|00002c90| 65 78 70 72 65 73 73 69 | 6f 6e 20 6f 62 6a 65 63 |expressi|on objec|
|00002ca0| 74 73 20 73 75 70 70 6f | 72 74 20 74 68 65 73 65 |ts suppo|rt these|
|00002cb0| 20 6d 65 74 68 6f 64 73 | 3a 0a 0a 5c 72 65 6e 65 | methods|:..\rene|
|00002cc0| 77 63 6f 6d 6d 61 6e 64 | 7b 5c 69 6e 64 65 78 73 |wcommand|{\indexs|
|00002cd0| 75 62 69 74 65 6d 7d 7b | 28 72 65 67 65 78 20 6d |ubitem}{|(regex m|
|00002ce0| 65 74 68 6f 64 29 7d 0a | 5c 62 65 67 69 6e 7b 66 |ethod)}.|\begin{f|
|00002cf0| 75 6e 63 64 65 73 63 7d | 7b 6d 61 74 63 68 7d 7b |uncdesc}|{match}{|
|00002d00| 73 74 72 69 6e 67 5c 6f | 70 74 69 6f 6e 61 6c 7b |string\o|ptional{|
|00002d10| 5c 2c 20 70 6f 73 7d 7d | 0a 20 20 52 65 74 75 72 |\, pos}}|. Retur|
|00002d20| 6e 20 68 6f 77 20 6d 61 | 6e 79 20 63 68 61 72 61 |n how ma|ny chara|
|00002d30| 63 74 65 72 73 20 61 74 | 20 74 68 65 20 62 65 67 |cters at| the beg|
|00002d40| 69 6e 6e 69 6e 67 20 6f | 66 20 5c 76 61 72 7b 73 |inning o|f \var{s|
|00002d50| 74 72 69 6e 67 7d 20 6d | 61 74 63 68 0a 20 20 74 |tring} m|atch. t|
|00002d60| 68 65 20 63 6f 6d 70 69 | 6c 65 64 20 72 65 67 75 |he compi|led regu|
|00002d70| 6c 61 72 20 65 78 70 72 | 65 73 73 69 6f 6e 2e 20 |lar expr|ession. |
|00002d80| 20 52 65 74 75 72 6e 20 | 5c 63 6f 64 65 7b 2d 31 | Return |\code{-1|
|00002d90| 7d 20 69 66 20 74 68 65 | 20 73 74 72 69 6e 67 0a |} if the| string.|
|00002da0| 20 20 64 6f 65 73 20 6e | 6f 74 20 6d 61 74 63 68 | does n|ot match|
|00002db0| 20 74 68 65 20 70 61 74 | 74 65 72 6e 20 28 74 68 | the pat|tern (th|
|00002dc0| 69 73 20 69 73 20 64 69 | 66 66 65 72 65 6e 74 20 |is is di|fferent |
|00002dd0| 66 72 6f 6d 20 61 20 7a | 65 72 6f 2d 6c 65 6e 67 |from a z|ero-leng|
|00002de0| 74 68 0a 20 20 6d 61 74 | 63 68 21 29 2e 0a 20 20 |th. mat|ch!).. |
|00002df0| 0a 20 20 54 68 65 20 6f | 70 74 69 6f 6e 61 6c 20 |. The o|ptional |
|00002e00| 73 65 63 6f 6e 64 20 70 | 61 72 61 6d 65 74 65 72 |second p|arameter|
|00002e10| 20 5c 76 61 72 7b 70 6f | 73 7d 20 67 69 76 65 73 | \var{po|s} gives|
|00002e20| 20 61 6e 20 69 6e 64 65 | 78 20 69 6e 20 74 68 65 | an inde|x in the|
|00002e30| 20 73 74 72 69 6e 67 0a | 20 20 77 68 65 72 65 20 | string.| where |
|00002e40| 74 68 65 20 73 65 61 72 | 63 68 20 69 73 20 74 6f |the sear|ch is to|
|00002e50| 20 73 74 61 72 74 3b 20 | 69 74 20 64 65 66 61 75 | start; |it defau|
|00002e60| 6c 74 73 20 74 6f 20 5c | 63 6f 64 65 7b 30 7d 2e |lts to \|code{0}.|
|00002e70| 20 20 54 68 69 73 20 69 | 73 20 6e 6f 74 0a 20 20 | This i|s not. |
|00002e80| 63 6f 6d 70 6c 65 74 65 | 6c 79 20 65 71 75 69 76 |complete|ly equiv|
|00002e90| 61 6c 65 6e 74 20 74 6f | 20 73 6c 69 63 69 6e 67 |alent to| slicing|
|00002ea0| 20 74 68 65 20 73 74 72 | 69 6e 67 3b 20 74 68 65 | the str|ing; the|
|00002eb0| 20 5c 63 6f 64 65 7b 27 | 5c 5e 27 7d 20 70 61 74 | \code{'|\^'} pat|
|00002ec0| 74 65 72 6e 0a 20 20 63 | 68 61 72 61 63 74 65 72 |tern. c|haracter|
|00002ed0| 20 6d 61 74 63 68 65 73 | 20 61 74 20 74 68 65 20 | matches| at the |
|00002ee0| 72 65 61 6c 20 62 65 67 | 69 6e 20 6f 66 20 74 68 |real beg|in of th|
|00002ef0| 65 20 73 74 72 69 6e 67 | 20 61 6e 64 20 61 74 20 |e string| and at |
|00002f00| 70 6f 73 69 74 69 6f 6e | 73 0a 20 20 6a 75 73 74 |position|s. just|
|00002f10| 20 61 66 74 65 72 20 61 | 20 6e 65 77 6c 69 6e 65 | after a| newline|
|00002f20| 2c 20 6e 6f 74 20 6e 65 | 63 65 73 73 61 72 69 6c |, not ne|cessaril|
|00002f30| 79 20 61 74 20 74 68 65 | 20 69 6e 64 65 78 20 77 |y at the| index w|
|00002f40| 68 65 72 65 20 74 68 65 | 20 73 65 61 72 63 68 0a |here the| search.|
|00002f50| 20 20 69 73 20 74 6f 20 | 73 74 61 72 74 2e 0a 5c | is to |start..\|
|00002f60| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0a 0a 5c |end{func|desc}..\|
|00002f70| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00002f80| 73 65 61 72 63 68 7d 7b | 73 74 72 69 6e 67 5c 6f |search}{|string\o|
|00002f90| 70 74 69 6f 6e 61 6c 7b | 5c 2c 20 70 6f 73 7d 7d |ptional{|\, pos}}|
|00002fa0| 0a 20 20 52 65 74 75 72 | 6e 20 74 68 65 20 66 69 |. Retur|n the fi|
|00002fb0| 72 73 74 20 70 6f 73 69 | 74 69 6f 6e 20 69 6e 20 |rst posi|tion in |
|00002fc0| 5c 76 61 72 7b 73 74 72 | 69 6e 67 7d 20 74 68 61 |\var{str|ing} tha|
|00002fd0| 74 20 6d 61 74 63 68 65 | 73 20 74 68 65 20 72 65 |t matche|s the re|
|00002fe0| 67 75 6c 61 72 0a 20 20 | 65 78 70 72 65 73 73 69 |gular. |expressi|
|00002ff0| 6f 6e 20 5c 63 6f 64 65 | 7b 70 61 74 74 65 72 6e |on \code|{pattern|
|00003000| 7d 2e 20 20 52 65 74 75 | 72 6e 20 5c 63 6f 64 65 |}. Retu|rn \code|
|00003010| 7b 2d 31 7d 20 69 66 20 | 6e 6f 20 70 6f 73 69 74 |{-1} if |no posit|
|00003020| 69 6f 6e 20 69 6e 20 74 | 68 65 0a 20 20 73 74 72 |ion in t|he. str|
|00003030| 69 6e 67 20 6d 61 74 63 | 68 65 73 20 74 68 65 20 |ing matc|hes the |
|00003040| 70 61 74 74 65 72 6e 20 | 28 74 68 69 73 20 69 73 |pattern |(this is|
|00003050| 20 64 69 66 66 65 72 65 | 6e 74 20 66 72 6f 6d 20 | differe|nt from |
|00003060| 61 20 7a 65 72 6f 2d 6c | 65 6e 67 74 68 0a 20 20 |a zero-l|ength. |
|00003070| 6d 61 74 63 68 20 61 6e | 79 77 68 65 72 65 21 29 |match an|ywhere!)|
|00003080| 2e 0a 20 20 0a 20 20 54 | 68 65 20 6f 70 74 69 6f |.. . T|he optio|
|00003090| 6e 61 6c 20 73 65 63 6f | 6e 64 20 70 61 72 61 6d |nal seco|nd param|
|000030a0| 65 74 65 72 20 68 61 73 | 20 74 68 65 20 73 61 6d |eter has| the sam|
|000030b0| 65 20 6d 65 61 6e 69 6e | 67 20 61 73 20 66 6f 72 |e meanin|g as for|
|000030c0| 20 74 68 65 0a 20 20 5c | 63 6f 64 65 7b 6d 61 74 | the. \|code{mat|
|000030d0| 63 68 7d 20 6d 65 74 68 | 6f 64 2e 0a 5c 65 6e 64 |ch} meth|od..\end|
|000030e0| 7b 66 75 6e 63 64 65 73 | 63 7d 0a 0a 5c 62 65 67 |{funcdes|c}..\beg|
|000030f0| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 67 72 6f |in{funcd|esc}{gro|
|00003100| 75 70 7d 7b 69 6e 64 65 | 78 5c 2c 20 69 6e 64 65 |up}{inde|x\, inde|
|00003110| 78 5c 2c 20 2e 2e 2e 7d | 0a 54 68 69 73 20 6d 65 |x\, ...}|.This me|
|00003120| 74 68 6f 64 20 69 73 20 | 6f 6e 6c 79 20 76 61 6c |thod is |only val|
|00003130| 69 64 20 77 68 65 6e 20 | 74 68 65 20 6c 61 73 74 |id when |the last|
|00003140| 20 63 61 6c 6c 20 74 6f | 20 74 68 65 20 5c 63 6f | call to| the \co|
|00003150| 64 65 7b 6d 61 74 63 68 | 7d 0a 6f 72 20 5c 63 6f |de{match|}.or \co|
|00003160| 64 65 7b 73 65 61 72 63 | 68 7d 20 6d 65 74 68 6f |de{searc|h} metho|
|00003170| 64 20 66 6f 75 6e 64 20 | 61 20 6d 61 74 63 68 2e |d found |a match.|
|00003180| 20 20 49 74 20 72 65 74 | 75 72 6e 73 20 6f 6e 65 | It ret|urns one|
|00003190| 20 6f 72 20 6d 6f 72 65 | 0a 67 72 6f 75 70 73 20 | or more|.groups |
|000031a0| 6f 66 20 74 68 65 20 6d | 61 74 63 68 2e 20 20 49 |of the m|atch. I|
|000031b0| 66 20 74 68 65 72 65 20 | 69 73 20 61 20 73 69 6e |f there |is a sin|
|000031c0| 67 6c 65 20 5c 76 61 72 | 7b 69 6e 64 65 78 7d 20 |gle \var|{index} |
|000031d0| 61 72 67 75 6d 65 6e 74 | 2c 0a 74 68 65 20 72 65 |argument|,.the re|
|000031e0| 73 75 6c 74 20 69 73 20 | 61 20 73 69 6e 67 6c 65 |sult is |a single|
|000031f0| 20 73 74 72 69 6e 67 3b | 20 69 66 20 74 68 65 72 | string;| if ther|
|00003200| 65 20 61 72 65 20 6d 75 | 6c 74 69 70 6c 65 20 61 |e are mu|ltiple a|
|00003210| 72 67 75 6d 65 6e 74 73 | 2c 20 74 68 65 0a 72 65 |rguments|, the.re|
|00003220| 73 75 6c 74 20 69 73 20 | 61 20 74 75 70 6c 65 20 |sult is |a tuple |
|00003230| 77 69 74 68 20 6f 6e 65 | 20 69 74 65 6d 20 70 65 |with one| item pe|
|00003240| 72 20 61 72 67 75 6d 65 | 6e 74 2e 20 20 49 66 20 |r argume|nt. If |
|00003250| 74 68 65 20 5c 76 61 72 | 7b 69 6e 64 65 78 7d 20 |the \var|{index} |
|00003260| 69 73 0a 7a 65 72 6f 2c | 20 74 68 65 20 63 6f 72 |is.zero,| the cor|
|00003270| 72 65 73 70 6f 6e 64 69 | 6e 67 20 72 65 74 75 72 |respondi|ng retur|
|00003280| 6e 20 76 61 6c 75 65 20 | 69 73 20 74 68 65 20 65 |n value |is the e|
|00003290| 6e 74 69 72 65 20 6d 61 | 74 63 68 69 6e 67 20 73 |ntire ma|tching s|
|000032a0| 74 72 69 6e 67 3b 20 69 | 66 0a 69 74 20 69 73 20 |tring; i|f.it is |
|000032b0| 69 6e 20 74 68 65 20 69 | 6e 63 6c 75 73 69 76 65 |in the i|nclusive|
|000032c0| 20 72 61 6e 67 65 20 5b | 31 2e 2e 39 39 5d 2c 20 | range [|1..99], |
|000032d0| 69 74 20 69 73 20 74 68 | 65 20 73 74 72 69 6e 67 |it is th|e string|
|000032e0| 20 6d 61 74 63 68 69 6e | 67 20 74 68 65 0a 74 68 | matchin|g the.th|
|000032f0| 65 20 63 6f 72 72 65 73 | 70 6f 6e 64 69 6e 67 20 |e corres|ponding |
|00003300| 70 61 72 65 6e 74 68 65 | 73 69 7a 65 64 20 67 72 |parenthe|sized gr|
|00003310| 6f 75 70 20 28 75 73 69 | 6e 67 20 74 68 65 20 64 |oup (usi|ng the d|
|00003320| 65 66 61 75 6c 74 20 73 | 79 6e 74 61 78 2c 0a 67 |efault s|yntax,.g|
|00003330| 72 6f 75 70 73 20 61 72 | 65 20 70 61 72 65 6e 74 |roups ar|e parent|
|00003340| 68 65 73 69 7a 65 64 20 | 75 73 69 6e 67 20 5c 63 |hesized |using \c|
|00003350| 6f 64 65 7b 5c 5c 28 7d | 20 61 6e 64 20 5c 63 6f |ode{\\(}| and \co|
|00003360| 64 65 7b 5c 5c 29 7d 29 | 2e 20 20 49 66 20 6e 6f |de{\\)})|. If no|
|00003370| 0a 73 75 63 68 20 67 72 | 6f 75 70 20 65 78 69 73 |.such gr|oup exis|
|00003380| 74 73 2c 20 74 68 65 20 | 63 6f 72 72 65 73 70 6f |ts, the |correspo|
|00003390| 6e 64 69 6e 67 20 72 65 | 73 75 6c 74 20 69 73 20 |nding re|sult is |
|000033a0| 5c 63 6f 64 65 7b 4e 6f | 6e 65 7d 2e 0a 0a 49 66 |\code{No|ne}...If|
|000033b0| 20 74 68 65 20 72 65 67 | 75 6c 61 72 20 65 78 70 | the reg|ular exp|
|000033c0| 72 65 73 73 69 6f 6e 20 | 77 61 73 20 63 6f 6d 70 |ression |was comp|
|000033d0| 69 6c 65 64 20 62 79 20 | 5c 63 6f 64 65 7b 73 79 |iled by |\code{sy|
|000033e0| 6d 63 6f 6d 70 7d 20 69 | 6e 73 74 65 61 64 20 6f |mcomp} i|nstead o|
|000033f0| 66 0a 5c 63 6f 64 65 7b | 63 6f 6d 70 69 6c 65 7d |f.\code{|compile}|
|00003400| 2c 20 74 68 65 20 5c 76 | 61 72 7b 69 6e 64 65 78 |, the \v|ar{index|
|00003410| 7d 20 61 72 67 75 6d 65 | 6e 74 73 20 6d 61 79 20 |} argume|nts may |
|00003420| 61 6c 73 6f 20 62 65 20 | 73 74 72 69 6e 67 73 0a |also be |strings.|
|00003430| 69 64 65 6e 74 69 66 79 | 69 6e 67 20 67 72 6f 75 |identify|ing grou|
|00003440| 70 73 20 62 79 20 74 68 | 65 69 72 20 67 72 6f 75 |ps by th|eir grou|
|00003450| 70 20 6e 61 6d 65 2e 0a | 5c 65 6e 64 7b 66 75 6e |p name..|\end{fun|
|00003460| 63 64 65 73 63 7d 0a 0a | 5c 6e 6f 69 6e 64 65 6e |cdesc}..|\noinden|
|00003470| 74 0a 43 6f 6d 70 69 6c | 65 64 20 72 65 67 75 6c |t.Compil|ed regul|
|00003480| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 73 20 73 |ar expre|ssions s|
|00003490| 75 70 70 6f 72 74 20 74 | 68 65 73 65 20 64 61 74 |upport t|hese dat|
|000034a0| 61 20 61 74 74 72 69 62 | 75 74 65 73 3a 0a 0a 5c |a attrib|utes:..\|
|000034b0| 72 65 6e 65 77 63 6f 6d | 6d 61 6e 64 7b 5c 69 6e |renewcom|mand{\in|
|000034c0| 64 65 78 73 75 62 69 74 | 65 6d 7d 7b 28 72 65 67 |dexsubit|em}{(reg|
|000034d0| 65 78 20 61 74 74 72 69 | 62 75 74 65 29 7d 0a 0a |ex attri|bute)}..|
|000034e0| 5c 62 65 67 69 6e 7b 64 | 61 74 61 64 65 73 63 7d |\begin{d|atadesc}|
|000034f0| 7b 72 65 67 73 7d 0a 57 | 68 65 6e 20 74 68 65 20 |{regs}.W|hen the |
|00003500| 6c 61 73 74 20 63 61 6c | 6c 20 74 6f 20 74 68 65 |last cal|l to the|
|00003510| 20 5c 63 6f 64 65 7b 6d | 61 74 63 68 7d 20 6f 72 | \code{m|atch} or|
|00003520| 20 5c 63 6f 64 65 7b 73 | 65 61 72 63 68 7d 20 6d | \code{s|earch} m|
|00003530| 65 74 68 6f 64 20 66 6f | 75 6e 64 20 61 0a 6d 61 |ethod fo|und a.ma|
|00003540| 74 63 68 2c 20 74 68 69 | 73 20 69 73 20 61 20 74 |tch, thi|s is a t|
|00003550| 75 70 6c 65 20 6f 66 20 | 70 61 69 72 73 20 6f 66 |uple of |pairs of|
|00003560| 20 69 6e 64 69 63 65 73 | 20 63 6f 72 72 65 73 70 | indices| corresp|
|00003570| 6f 6e 64 69 6e 67 20 74 | 6f 20 74 68 65 0a 62 65 |onding t|o the.be|
|00003580| 67 69 6e 6e 69 6e 67 20 | 61 6e 64 20 65 6e 64 20 |ginning |and end |
|00003590| 6f 66 20 61 6c 6c 20 70 | 61 72 65 6e 74 68 65 73 |of all p|arenthes|
|000035a0| 69 7a 65 64 20 67 72 6f | 75 70 73 20 69 6e 20 74 |ized gro|ups in t|
|000035b0| 68 65 20 70 61 74 74 65 | 72 6e 2e 20 20 49 6e 64 |he patte|rn. Ind|
|000035c0| 69 63 65 73 0a 61 72 65 | 20 72 65 6c 61 74 69 76 |ices.are| relativ|
|000035d0| 65 20 74 6f 20 74 68 65 | 20 73 74 72 69 6e 67 20 |e to the| string |
|000035e0| 61 72 67 75 6d 65 6e 74 | 20 70 61 73 73 65 64 20 |argument| passed |
|000035f0| 74 6f 20 5c 63 6f 64 65 | 7b 6d 61 74 63 68 7d 20 |to \code|{match} |
|00003600| 6f 72 0a 5c 63 6f 64 65 | 7b 73 65 61 72 63 68 7d |or.\code|{search}|
|00003610| 2e 20 20 54 68 65 20 30 | 2d 74 68 20 74 75 70 6c |. The 0|-th tupl|
|00003620| 65 20 67 69 76 65 73 20 | 74 68 65 20 62 65 67 69 |e gives |the begi|
|00003630| 6e 6e 69 6e 67 20 61 6e | 64 20 65 6e 64 20 6f 72 |nning an|d end or|
|00003640| 20 74 68 65 0a 77 68 6f | 6c 65 20 70 61 74 74 65 | the.who|le patte|
|00003650| 72 6e 2e 20 20 57 68 65 | 6e 20 74 68 65 20 6c 61 |rn. Whe|n the la|
|00003660| 73 74 20 6d 61 74 63 68 | 20 6f 72 20 73 65 61 72 |st match| or sear|
|00003670| 63 68 20 66 61 69 6c 65 | 64 2c 20 74 68 69 73 20 |ch faile|d, this |
|00003680| 69 73 0a 5c 63 6f 64 65 | 7b 4e 6f 6e 65 7d 2e 0a |is.\code|{None}..|
|00003690| 5c 65 6e 64 7b 64 61 74 | 61 64 65 73 63 7d 0a 0a |\end{dat|adesc}..|
|000036a0| 5c 62 65 67 69 6e 7b 64 | 61 74 61 64 65 73 63 7d |\begin{d|atadesc}|
|000036b0| 7b 6c 61 73 74 7d 0a 57 | 68 65 6e 20 74 68 65 20 |{last}.W|hen the |
|000036c0| 6c 61 73 74 20 63 61 6c | 6c 20 74 6f 20 74 68 65 |last cal|l to the|
|000036d0| 20 5c 63 6f 64 65 7b 6d | 61 74 63 68 7d 20 6f 72 | \code{m|atch} or|
|000036e0| 20 5c 63 6f 64 65 7b 73 | 65 61 72 63 68 7d 20 6d | \code{s|earch} m|
|000036f0| 65 74 68 6f 64 20 66 6f | 75 6e 64 20 61 0a 6d 61 |ethod fo|und a.ma|
|00003700| 74 63 68 2c 20 74 68 69 | 73 20 69 73 20 74 68 65 |tch, thi|s is the|
|00003710| 20 73 74 72 69 6e 67 20 | 61 72 67 75 6d 65 6e 74 | string |argument|
|00003720| 20 70 61 73 73 65 64 20 | 74 6f 20 74 68 61 74 20 | passed |to that |
|00003730| 6d 65 74 68 6f 64 2e 20 | 20 57 68 65 6e 20 74 68 |method. | When th|
|00003740| 65 0a 6c 61 73 74 20 6d | 61 74 63 68 20 6f 72 20 |e.last m|atch or |
|00003750| 73 65 61 72 63 68 20 66 | 61 69 6c 65 64 2c 20 74 |search f|ailed, t|
|00003760| 68 69 73 20 69 73 20 5c | 63 6f 64 65 7b 4e 6f 6e |his is \|code{Non|
|00003770| 65 7d 2e 0a 5c 65 6e 64 | 7b 64 61 74 61 64 65 73 |e}..\end|{datades|
|00003780| 63 7d 0a 0a 5c 62 65 67 | 69 6e 7b 64 61 74 61 64 |c}..\beg|in{datad|
|00003790| 65 73 63 7d 7b 74 72 61 | 6e 73 6c 61 74 65 7d 0a |esc}{tra|nslate}.|
|000037a0| 54 68 69 73 20 69 73 20 | 74 68 65 20 76 61 6c 75 |This is |the valu|
|000037b0| 65 20 6f 66 20 74 68 65 | 20 5c 76 61 72 7b 74 72 |e of the| \var{tr|
|000037c0| 61 6e 73 6c 61 74 65 7d | 20 61 72 67 75 6d 65 6e |anslate}| argumen|
|000037d0| 74 20 74 6f 0a 5c 63 6f | 64 65 7b 72 65 67 65 78 |t to.\co|de{regex|
|000037e0| 2e 63 6f 6d 70 69 6c 65 | 7d 20 74 68 61 74 20 63 |.compile|} that c|
|000037f0| 72 65 61 74 65 64 20 74 | 68 69 73 20 72 65 67 75 |reated t|his regu|
|00003800| 6c 61 72 20 65 78 70 72 | 65 73 73 69 6f 6e 20 6f |lar expr|ession o|
|00003810| 62 6a 65 63 74 2e 20 20 | 49 66 0a 74 68 65 20 5c |bject. |If.the \|
|00003820| 76 61 72 7b 74 72 61 6e | 73 6c 61 74 65 7d 20 61 |var{tran|slate} a|
|00003830| 72 67 75 6d 65 6e 74 20 | 77 61 73 20 6f 6d 69 74 |rgument |was omit|
|00003840| 74 65 64 20 69 6e 20 74 | 68 65 20 5c 63 6f 64 65 |ted in t|he \code|
|00003850| 7b 72 65 67 65 78 2e 63 | 6f 6d 70 69 6c 65 7d 0a |{regex.c|ompile}.|
|00003860| 63 61 6c 6c 2c 20 74 68 | 69 73 20 69 73 20 5c 63 |call, th|is is \c|
|00003870| 6f 64 65 7b 4e 6f 6e 65 | 7d 2e 0a 5c 65 6e 64 7b |ode{None|}..\end{|
|00003880| 64 61 74 61 64 65 73 63 | 7d 0a 0a 5c 62 65 67 69 |datadesc|}..\begi|
|00003890| 6e 7b 64 61 74 61 64 65 | 73 63 7d 7b 67 69 76 65 |n{datade|sc}{give|
|000038a0| 6e 70 61 74 7d 0a 54 68 | 65 20 72 65 67 75 6c 61 |npat}.Th|e regula|
|000038b0| 72 20 65 78 70 72 65 73 | 73 69 6f 6e 20 70 61 74 |r expres|sion pat|
|000038c0| 74 65 72 6e 20 61 73 20 | 70 61 73 73 65 64 20 74 |tern as |passed t|
|000038d0| 6f 20 5c 63 6f 64 65 7b | 63 6f 6d 70 69 6c 65 7d |o \code{|compile}|
|000038e0| 20 6f 72 0a 5c 63 6f 64 | 65 7b 73 79 6d 63 6f 6d | or.\cod|e{symcom|
|000038f0| 70 7d 2e 0a 5c 65 6e 64 | 7b 64 61 74 61 64 65 73 |p}..\end|{datades|
|00003900| 63 7d 0a 0a 5c 62 65 67 | 69 6e 7b 64 61 74 61 64 |c}..\beg|in{datad|
|00003910| 65 73 63 7d 7b 72 65 61 | 6c 70 61 74 7d 0a 54 68 |esc}{rea|lpat}.Th|
|00003920| 65 20 72 65 67 75 6c 61 | 72 20 65 78 70 72 65 73 |e regula|r expres|
|00003930| 73 69 6f 6e 20 61 66 74 | 65 72 20 73 74 72 69 70 |sion aft|er strip|
|00003940| 70 69 6e 67 20 74 68 65 | 20 67 72 6f 75 70 20 6e |ping the| group n|
|00003950| 61 6d 65 73 20 66 6f 72 | 20 72 65 67 75 6c 61 72 |ames for| regular|
|00003960| 0a 65 78 70 72 65 73 73 | 69 6f 6e 73 20 63 6f 6d |.express|ions com|
|00003970| 70 69 6c 65 64 20 77 69 | 74 68 20 5c 63 6f 64 65 |piled wi|th \code|
|00003980| 7b 73 79 6d 63 6f 6d 70 | 7d 2e 20 20 53 61 6d 65 |{symcomp|}. Same|
|00003990| 20 61 73 20 5c 63 6f 64 | 65 7b 67 69 76 65 6e 70 | as \cod|e{givenp|
|000039a0| 61 74 7d 0a 6f 74 68 65 | 72 77 69 73 65 2e 0a 5c |at}.othe|rwise..\|
|000039b0| 65 6e 64 7b 64 61 74 61 | 64 65 73 63 7d 0a 0a 5c |end{data|desc}..\|
|000039c0| 62 65 67 69 6e 7b 64 61 | 74 61 64 65 73 63 7d 7b |begin{da|tadesc}{|
|000039d0| 67 72 6f 75 70 69 6e 64 | 65 78 7d 0a 41 20 64 69 |groupind|ex}.A di|
|000039e0| 63 74 69 6f 6e 61 72 79 | 20 67 69 76 69 6e 67 20 |ctionary| giving |
|000039f0| 74 68 65 20 6d 61 70 70 | 69 6e 67 20 66 72 6f 6d |the mapp|ing from|
|00003a00| 20 73 79 6d 62 6f 6c 69 | 63 20 67 72 6f 75 70 20 | symboli|c group |
|00003a10| 6e 61 6d 65 73 20 74 6f | 20 6e 75 6d 65 72 69 63 |names to| numeric|
|00003a20| 61 6c 0a 67 72 6f 75 70 | 20 69 6e 64 69 63 65 73 |al.group| indices|
|00003a30| 20 66 6f 72 20 72 65 67 | 75 6c 61 72 20 65 78 70 | for reg|ular exp|
|00003a40| 72 65 73 73 69 6f 6e 73 | 20 63 6f 6d 70 69 6c 65 |ressions| compile|
|00003a50| 64 20 77 69 74 68 20 5c | 63 6f 64 65 7b 73 79 6d |d with \|code{sym|
|00003a60| 63 6f 6d 70 7d 2e 0a 5c | 63 6f 64 65 7b 4e 6f 6e |comp}..\|code{Non|
|00003a70| 65 7d 20 6f 74 68 65 72 | 77 69 73 65 2e 0a 5c 65 |e} other|wise..\e|
|00003a80| 6e 64 7b 64 61 74 61 64 | 65 73 63 7d 0a |nd{datad|esc}. |
+--------+-------------------------+-------------------------+--------+--------+