home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
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, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [R*ch] |
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 0d 0d 5c 62 69 6d |de{regex|}}..\bim|
|00000030| 6f 64 69 6e 64 65 78 7b | 72 65 67 65 78 7d 0d 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 0d 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 0d 0d 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 2c 0d 77 69 74 68 20 | 6f 6e 65 20 65 78 63 65 |s,.with |one exce|
|00000100| 70 74 69 6f 6e 2e 20 20 | 54 68 65 72 65 20 69 73 |ption. |There is|
|00000110| 0d 61 20 77 61 79 20 74 | 6f 20 63 68 61 6e 67 65 |.a way t|o change|
|00000120| 20 74 68 65 20 73 79 6e | 74 61 78 20 74 6f 20 6d | the syn|tax to m|
|00000130| 61 74 63 68 20 74 68 61 | 74 20 6f 66 20 73 65 76 |atch tha|t of sev|
|00000140| 65 72 61 6c 20 77 65 6c | 6c 2d 6b 6e 6f 77 6e 0d |eral wel|l-known.|
|00000150| 5c 55 4e 49 58 7b 7d 20 | 75 74 69 6c 69 74 69 65 |\UNIX{} |utilitie|
|00000160| 73 2e 20 20 54 68 65 20 | 65 78 63 65 70 74 69 6f |s. The |exceptio|
|00000170| 6e 20 69 73 20 74 68 61 | 74 20 45 6d 61 63 73 27 |n is tha|t Emacs'|
|00000180| 20 5c 73 61 6d 70 7b 5c | 65 20 73 7d 0d 70 61 74 | \samp{\|e s}.pat|
|00000190| 74 65 72 6e 20 69 73 20 | 6e 6f 74 20 73 75 70 70 |tern is |not supp|
|000001a0| 6f 72 74 65 64 2c 20 73 | 69 6e 63 65 20 74 68 65 |orted, s|ince the|
|000001b0| 20 6f 72 69 67 69 6e 61 | 6c 20 69 6d 70 6c 65 6d | origina|l implem|
|000001c0| 65 6e 74 61 74 69 6f 6e | 20 72 65 66 65 72 65 6e |entation| referen|
|000001d0| 63 65 73 0d 74 68 65 20 | 45 6d 61 63 73 20 73 79 |ces.the |Emacs sy|
|000001e0| 6e 74 61 78 20 74 61 62 | 6c 65 73 2e 0d 0d 54 68 |ntax tab|les...Th|
|000001f0| 69 73 20 6d 6f 64 75 6c | 65 20 69 73 20 38 2d 62 |is modul|e is 8-b|
|00000200| 69 74 20 63 6c 65 61 6e | 3a 20 62 6f 74 68 20 70 |it clean|: both p|
|00000210| 61 74 74 65 72 6e 73 20 | 61 6e 64 20 73 74 72 69 |atterns |and stri|
|00000220| 6e 67 73 20 6d 61 79 20 | 63 6f 6e 74 61 69 6e 20 |ngs may |contain |
|00000230| 6e 75 6c 6c 0d 62 79 74 | 65 73 20 61 6e 64 20 63 |null.byt|es and c|
|00000240| 68 61 72 61 63 74 65 72 | 73 20 77 68 6f 73 65 20 |haracter|s whose |
|00000250| 68 69 67 68 20 62 69 74 | 20 69 73 20 73 65 74 2e |high bit| is set.|
|00000260| 0d 0d 5c 73 74 72 6f 6e | 67 7b 50 6c 65 61 73 65 |..\stron|g{Please|
|00000270| 20 6e 6f 74 65 3a 7d 20 | 54 68 65 72 65 20 69 73 | note:} |There is|
|00000280| 20 61 20 6c 69 74 74 6c | 65 2d 6b 6e 6f 77 6e 20 | a littl|e-known |
|00000290| 66 61 63 74 20 61 62 6f | 75 74 20 50 79 74 68 6f |fact abo|ut Pytho|
|000002a0| 6e 20 73 74 72 69 6e 67 | 0d 6c 69 74 65 72 61 6c |n string|.literal|
|000002b0| 73 20 77 68 69 63 68 20 | 6d 65 61 6e 73 20 74 68 |s which |means th|
|000002c0| 61 74 20 79 6f 75 20 64 | 6f 6e 27 74 20 75 73 75 |at you d|on't usu|
|000002d0| 61 6c 6c 79 20 68 61 76 | 65 20 74 6f 20 77 6f 72 |ally hav|e to wor|
|000002e0| 72 79 20 61 62 6f 75 74 | 0d 64 6f 75 62 6c 69 6e |ry about|.doublin|
|000002f0| 67 20 62 61 63 6b 73 6c | 61 73 68 65 73 2c 20 65 |g backsl|ashes, e|
|00000300| 76 65 6e 20 74 68 6f 75 | 67 68 20 74 68 65 79 20 |ven thou|gh they |
|00000310| 61 72 65 20 75 73 65 64 | 20 74 6f 20 65 73 63 61 |are used| to esca|
|00000320| 70 65 20 73 70 65 63 69 | 61 6c 0d 63 68 61 72 61 |pe speci|al.chara|
|00000330| 63 74 65 72 73 20 69 6e | 20 73 74 72 69 6e 67 20 |cters in| string |
|00000340| 6c 69 74 65 72 61 6c 73 | 20 61 73 20 77 65 6c 6c |literals| as well|
|00000350| 20 61 73 20 69 6e 20 72 | 65 67 75 6c 61 72 20 65 | as in r|egular e|
|00000360| 78 70 72 65 73 73 69 6f | 6e 73 2e 20 20 54 68 69 |xpressio|ns. Thi|
|00000370| 73 0d 69 73 20 62 65 63 | 61 75 73 65 20 50 79 74 |s.is bec|ause Pyt|
|00000380| 68 6f 6e 20 64 6f 65 73 | 6e 27 74 20 72 65 6d 6f |hon does|n't remo|
|00000390| 76 65 20 62 61 63 6b 73 | 6c 61 73 68 65 73 20 66 |ve backs|lashes f|
|000003a0| 72 6f 6d 20 73 74 72 69 | 6e 67 20 6c 69 74 65 72 |rom stri|ng liter|
|000003b0| 61 6c 73 20 69 66 0d 74 | 68 65 79 20 61 72 65 20 |als if.t|hey are |
|000003c0| 66 6f 6c 6c 6f 77 65 64 | 20 62 79 20 61 6e 20 75 |followed| by an u|
|000003d0| 6e 72 65 63 6f 67 6e 69 | 7a 65 64 20 65 73 63 61 |nrecogni|zed esca|
|000003e0| 70 65 20 63 68 61 72 61 | 63 74 65 72 2e 0d 5c 65 |pe chara|cter..\e|
|000003f0| 6d 70 68 7b 48 6f 77 65 | 76 65 72 7d 2c 20 69 66 |mph{Howe|ver}, if|
|00000400| 20 79 6f 75 20 77 61 6e | 74 20 74 6f 20 69 6e 63 | you wan|t to inc|
|00000410| 6c 75 64 65 20 61 20 6c | 69 74 65 72 61 6c 20 5c |lude a l|iteral \|
|00000420| 64 66 6e 7b 62 61 63 6b | 73 6c 61 73 68 7d 20 69 |dfn{back|slash} i|
|00000430| 6e 20 61 0d 72 65 67 75 | 6c 61 72 20 65 78 70 72 |n a.regu|lar expr|
|00000440| 65 73 73 69 6f 6e 20 72 | 65 70 72 65 73 65 6e 74 |ession r|epresent|
|00000450| 65 64 20 61 73 20 61 20 | 73 74 72 69 6e 67 20 6c |ed as a |string l|
|00000460| 69 74 65 72 61 6c 2c 20 | 79 6f 75 20 68 61 76 65 |iteral, |you have|
|00000470| 20 74 6f 0d 5c 65 6d 70 | 68 7b 71 75 61 64 72 75 | to.\emp|h{quadru|
|00000480| 70 6c 65 7d 20 69 74 2e | 20 20 45 2e 67 2e 5c 20 |ple} it.| E.g.\ |
|00000490| 20 74 6f 20 65 78 74 72 | 61 63 74 20 5c 4c 61 54 | to extr|act \LaT|
|000004a0| 65 58 5c 20 5c 73 61 6d | 70 7b 5c 65 20 73 65 63 |eX\ \sam|p{\e sec|
|000004b0| 74 69 6f 6e 5c 7b 7b 5c | 72 6d 0d 5c 6c 64 6f 74 |tion\{{\|rm.\ldot|
|000004c0| 73 7d 5c 7d 7d 20 68 65 | 61 64 65 72 73 20 66 72 |s}\}} he|aders fr|
|000004d0| 6f 6d 20 61 20 64 6f 63 | 75 6d 65 6e 74 2c 20 79 |om a doc|ument, y|
|000004e0| 6f 75 20 63 61 6e 20 75 | 73 65 20 74 68 69 73 20 |ou can u|se this |
|000004f0| 70 61 74 74 65 72 6e 3a | 0d 5c 63 6f 64 65 7b 27 |pattern:|.\code{'|
|00000500| 5c 65 20 5c 65 20 5c 65 | 5c 65 20 73 65 63 74 69 |\e \e \e|\e secti|
|00000510| 6f 6e 5c 7b 5c 65 20 28 | 2e 2a 5c 65 20 29 5c 7d |on\{\e (|.*\e )\}|
|00000520| 27 7d 2e 0d 0d 54 68 65 | 20 6d 6f 64 75 6c 65 20 |'}...The| module |
|00000530| 64 65 66 69 6e 65 73 20 | 74 68 65 73 65 20 66 75 |defines |these fu|
|00000540| 6e 63 74 69 6f 6e 73 2c | 20 61 6e 64 20 61 6e 20 |nctions,| and an |
|00000550| 65 78 63 65 70 74 69 6f | 6e 3a 0d 0d 5c 72 65 6e |exceptio|n:..\ren|
|00000560| 65 77 63 6f 6d 6d 61 6e | 64 7b 5c 69 6e 64 65 78 |ewcomman|d{\index|
|00000570| 73 75 62 69 74 65 6d 7d | 7b 28 69 6e 20 6d 6f 64 |subitem}|{(in mod|
|00000580| 75 6c 65 20 72 65 67 65 | 78 29 7d 0d 0d 5c 62 65 |ule rege|x)}..\be|
|00000590| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 6d 61 |gin{func|desc}{ma|
|000005a0| 74 63 68 7d 7b 70 61 74 | 74 65 72 6e 5c 2c 20 73 |tch}{pat|tern\, s|
|000005b0| 74 72 69 6e 67 7d 0d 20 | 20 52 65 74 75 72 6e 20 |tring}. | Return |
|000005c0| 68 6f 77 20 6d 61 6e 79 | 20 63 68 61 72 61 63 74 |how many| charact|
|000005d0| 65 72 73 20 61 74 20 74 | 68 65 20 62 65 67 69 6e |ers at t|he begin|
|000005e0| 6e 69 6e 67 20 6f 66 20 | 5c 76 61 72 7b 73 74 72 |ning of |\var{str|
|000005f0| 69 6e 67 7d 20 6d 61 74 | 63 68 0d 20 20 74 68 65 |ing} mat|ch. the|
|00000600| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00000610| 69 6f 6e 20 5c 76 61 72 | 7b 70 61 74 74 65 72 6e |ion \var|{pattern|
|00000620| 7d 2e 20 20 52 65 74 75 | 72 6e 20 5c 63 6f 64 65 |}. Retu|rn \code|
|00000630| 7b 2d 31 7d 20 69 66 20 | 74 68 65 0d 20 20 73 74 |{-1} if |the. st|
|00000640| 72 69 6e 67 20 64 6f 65 | 73 20 6e 6f 74 20 6d 61 |ring doe|s not ma|
|00000650| 74 63 68 20 74 68 65 20 | 70 61 74 74 65 72 6e 20 |tch the |pattern |
|00000660| 28 74 68 69 73 20 69 73 | 20 64 69 66 66 65 72 65 |(this is| differe|
|00000670| 6e 74 20 66 72 6f 6d 20 | 61 0d 20 20 7a 65 72 6f |nt from |a. zero|
|00000680| 2d 6c 65 6e 67 74 68 20 | 6d 61 74 63 68 21 29 2e |-length |match!).|
|00000690| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|000006a0| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|000006b0| 7d 7b 73 65 61 72 63 68 | 7d 7b 70 61 74 74 65 72 |}{search|}{patter|
|000006c0| 6e 5c 2c 20 73 74 72 69 | 6e 67 7d 0d 20 20 52 65 |n\, stri|ng}. Re|
|000006d0| 74 75 72 6e 20 74 68 65 | 20 66 69 72 73 74 20 70 |turn the| first p|
|000006e0| 6f 73 69 74 69 6f 6e 20 | 69 6e 20 5c 76 61 72 7b |osition |in \var{|
|000006f0| 73 74 72 69 6e 67 7d 20 | 74 68 61 74 20 6d 61 74 |string} |that mat|
|00000700| 63 68 65 73 20 74 68 65 | 20 72 65 67 75 6c 61 72 |ches the| regular|
|00000710| 0d 20 20 65 78 70 72 65 | 73 73 69 6f 6e 20 5c 76 |. expre|ssion \v|
|00000720| 61 72 7b 70 61 74 74 65 | 72 6e 7d 2e 20 20 52 65 |ar{patte|rn}. Re|
|00000730| 74 75 72 6e 20 2d 31 20 | 69 66 20 6e 6f 20 70 6f |turn -1 |if no po|
|00000740| 73 69 74 69 6f 6e 20 69 | 6e 20 74 68 65 20 73 74 |sition i|n the st|
|00000750| 72 69 6e 67 0d 20 20 6d | 61 74 63 68 65 73 20 74 |ring. m|atches t|
|00000760| 68 65 20 70 61 74 74 65 | 72 6e 20 28 74 68 69 73 |he patte|rn (this|
|00000770| 20 69 73 20 64 69 66 66 | 65 72 65 6e 74 20 66 72 | is diff|erent fr|
|00000780| 6f 6d 20 61 20 7a 65 72 | 6f 2d 6c 65 6e 67 74 68 |om a zer|o-length|
|00000790| 20 6d 61 74 63 68 0d 20 | 20 61 6e 79 77 68 65 72 | match. | anywher|
|000007a0| 65 21 29 2e 0d 5c 65 6e | 64 7b 66 75 6e 63 64 65 |e!)..\en|d{funcde|
|000007b0| 73 63 7d 0d 0d 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|000007c0| 64 65 73 63 7d 7b 63 6f | 6d 70 69 6c 65 7d 7b 70 |desc}{co|mpile}{p|
|000007d0| 61 74 74 65 72 6e 5c 6f | 70 74 69 6f 6e 61 6c 7b |attern\o|ptional{|
|000007e0| 5c 2c 20 74 72 61 6e 73 | 6c 61 74 65 7d 7d 0d 20 |\, trans|late}}. |
|000007f0| 20 43 6f 6d 70 69 6c 65 | 20 61 20 72 65 67 75 6c | Compile| a regul|
|00000800| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 20 70 61 |ar expre|ssion pa|
|00000810| 74 74 65 72 6e 20 69 6e | 74 6f 20 61 20 72 65 67 |ttern in|to a reg|
|00000820| 75 6c 61 72 20 65 78 70 | 72 65 73 73 69 6f 6e 0d |ular exp|ression.|
|00000830| 20 20 6f 62 6a 65 63 74 | 2c 20 77 68 69 63 68 20 | object|, which |
|00000840| 63 61 6e 20 62 65 20 75 | 73 65 64 20 66 6f 72 20 |can be u|sed for |
|00000850| 6d 61 74 63 68 69 6e 67 | 20 75 73 69 6e 67 20 69 |matching| using i|
|00000860| 74 73 20 5c 63 6f 64 65 | 7b 6d 61 74 63 68 7d 20 |ts \code|{match} |
|00000870| 61 6e 64 0d 20 20 5c 63 | 6f 64 65 7b 73 65 61 72 |and. \c|ode{sear|
|00000880| 63 68 7d 20 6d 65 74 68 | 6f 64 73 2c 20 64 65 73 |ch} meth|ods, des|
|00000890| 63 72 69 62 65 64 20 62 | 65 6c 6f 77 2e 20 20 54 |cribed b|elow. T|
|000008a0| 68 65 20 6f 70 74 69 6f | 6e 61 6c 20 61 72 67 75 |he optio|nal argu|
|000008b0| 6d 65 6e 74 0d 20 20 5c | 76 61 72 7b 74 72 61 6e |ment. \|var{tran|
|000008c0| 73 6c 61 74 65 7d 2c 20 | 69 66 20 70 72 65 73 65 |slate}, |if prese|
|000008d0| 6e 74 2c 20 6d 75 73 74 | 20 62 65 20 61 20 32 35 |nt, must| be a 25|
|000008e0| 36 2d 63 68 61 72 61 63 | 74 65 72 20 73 74 72 69 |6-charac|ter stri|
|000008f0| 6e 67 0d 20 20 69 6e 64 | 69 63 61 74 69 6e 67 20 |ng. ind|icating |
|00000900| 68 6f 77 20 63 68 61 72 | 61 63 74 65 72 73 20 28 |how char|acters (|
|00000910| 62 6f 74 68 20 6f 66 20 | 74 68 65 20 70 61 74 74 |both of |the patt|
|00000920| 65 72 6e 20 61 6e 64 20 | 6f 66 20 74 68 65 20 73 |ern and |of the s|
|00000930| 74 72 69 6e 67 73 20 74 | 6f 0d 20 20 62 65 20 6d |trings t|o. be m|
|00000940| 61 74 63 68 65 64 29 20 | 61 72 65 20 74 72 61 6e |atched) |are tran|
|00000950| 73 6c 61 74 65 64 20 62 | 65 66 6f 72 65 20 63 6f |slated b|efore co|
|00000960| 6d 70 61 72 69 6e 67 20 | 74 68 65 6d 3b 20 74 68 |mparing |them; th|
|00000970| 65 20 5c 63 6f 64 65 7b | 69 7d 2d 74 68 0d 20 20 |e \code{|i}-th. |
|00000980| 65 6c 65 6d 65 6e 74 20 | 6f 66 20 74 68 65 20 73 |element |of the s|
|00000990| 74 72 69 6e 67 20 67 69 | 76 65 73 20 74 68 65 20 |tring gi|ves the |
|000009a0| 74 72 61 6e 73 6c 61 74 | 69 6f 6e 20 66 6f 72 20 |translat|ion for |
|000009b0| 74 68 65 20 63 68 61 72 | 61 63 74 65 72 20 77 69 |the char|acter wi|
|000009c0| 74 68 0d 20 20 5c 41 53 | 43 49 49 7b 7d 20 63 6f |th. \AS|CII{} co|
|000009d0| 64 65 20 5c 63 6f 64 65 | 7b 69 7d 2e 20 20 54 68 |de \code|{i}. Th|
|000009e0| 69 73 20 63 61 6e 20 62 | 65 20 75 73 65 64 20 74 |is can b|e used t|
|000009f0| 6f 20 69 6d 70 6c 65 6d | 65 6e 74 0d 20 20 63 61 |o implem|ent. ca|
|00000a00| 73 65 2d 69 6e 73 65 6e | 73 69 74 69 76 65 20 6d |se-insen|sitive m|
|00000a10| 61 74 63 68 69 6e 67 3b | 20 73 65 65 20 74 68 65 |atching;| see the|
|00000a20| 20 5c 63 6f 64 65 7b 63 | 61 73 65 66 6f 6c 64 7d | \code{c|asefold}|
|00000a30| 20 64 61 74 61 20 69 74 | 65 6d 20 62 65 6c 6f 77 | data it|em below|
|00000a40| 2e 0d 0d 20 20 54 68 65 | 20 73 65 71 75 65 6e 63 |... The| sequenc|
|00000a50| 65 0d 0d 5c 62 63 6f 64 | 65 5c 62 65 67 69 6e 7b |e..\bcod|e\begin{|
|00000a60| 76 65 72 62 61 74 69 6d | 7d 0d 70 72 6f 67 20 3d |verbatim|}.prog =|
|00000a70| 20 72 65 67 65 78 2e 63 | 6f 6d 70 69 6c 65 28 70 | regex.c|ompile(p|
|00000a80| 61 74 29 0d 72 65 73 75 | 6c 74 20 3d 20 70 72 6f |at).resu|lt = pro|
|00000a90| 67 2e 6d 61 74 63 68 28 | 73 74 72 29 0d 5c 65 6e |g.match(|str).\en|
|00000aa0| 64 7b 76 65 72 62 61 74 | 69 6d 7d 5c 65 63 6f 64 |d{verbat|im}\ecod|
|00000ab0| 65 0d 0d 69 73 20 65 71 | 75 69 76 61 6c 65 6e 74 |e..is eq|uivalent|
|00000ac0| 20 74 6f 0d 0d 5c 62 63 | 6f 64 65 5c 62 65 67 69 | to..\bc|ode\begi|
|00000ad0| 6e 7b 76 65 72 62 61 74 | 69 6d 7d 0d 72 65 73 75 |n{verbat|im}.resu|
|00000ae0| 6c 74 20 3d 20 72 65 67 | 65 78 2e 6d 61 74 63 68 |lt = reg|ex.match|
|00000af0| 28 70 61 74 2c 20 73 74 | 72 29 0d 5c 65 6e 64 7b |(pat, st|r).\end{|
|00000b00| 76 65 72 62 61 74 69 6d | 7d 5c 65 63 6f 64 65 0d |verbatim|}\ecode.|
|00000b10| 0d 62 75 74 20 74 68 65 | 20 76 65 72 73 69 6f 6e |.but the| version|
|00000b20| 20 75 73 69 6e 67 20 5c | 63 6f 64 65 7b 63 6f 6d | using \|code{com|
|00000b30| 70 69 6c 65 28 29 7d 20 | 69 73 20 6d 6f 72 65 20 |pile()} |is more |
|00000b40| 65 66 66 69 63 69 65 6e | 74 20 77 68 65 6e 20 6d |efficien|t when m|
|00000b50| 75 6c 74 69 70 6c 65 0d | 72 65 67 75 6c 61 72 20 |ultiple.|regular |
|00000b60| 65 78 70 72 65 73 73 69 | 6f 6e 73 20 61 72 65 20 |expressi|ons are |
|00000b70| 75 73 65 64 20 63 6f 6e | 63 75 72 72 65 6e 74 6c |used con|currentl|
|00000b80| 79 20 69 6e 20 61 20 73 | 69 6e 67 6c 65 20 70 72 |y in a s|ingle pr|
|00000b90| 6f 67 72 61 6d 2e 20 20 | 28 54 68 65 0d 63 6f 6d |ogram. |(The.com|
|00000ba0| 70 69 6c 65 64 20 76 65 | 72 73 69 6f 6e 20 6f 66 |piled ve|rsion of|
|00000bb0| 20 74 68 65 20 6c 61 73 | 74 20 70 61 74 74 65 72 | the las|t patter|
|00000bc0| 6e 20 70 61 73 73 65 64 | 20 74 6f 20 5c 63 6f 64 |n passed| to \cod|
|00000bd0| 65 7b 72 65 67 65 78 2e | 6d 61 74 63 68 28 29 7d |e{regex.|match()}|
|00000be0| 20 6f 72 0d 5c 63 6f 64 | 65 7b 72 65 67 65 78 2e | or.\cod|e{regex.|
|00000bf0| 73 65 61 72 63 68 28 29 | 7d 20 69 73 20 63 61 63 |search()|} is cac|
|00000c00| 68 65 64 2c 20 73 6f 20 | 70 72 6f 67 72 61 6d 73 |hed, so |programs|
|00000c10| 20 74 68 61 74 20 75 73 | 65 20 6f 6e 6c 79 20 61 | that us|e only a|
|00000c20| 20 73 69 6e 67 6c 65 0d | 72 65 67 75 6c 61 72 20 | single.|regular |
|00000c30| 65 78 70 72 65 73 73 69 | 6f 6e 20 61 74 20 61 20 |expressi|on at a |
|00000c40| 74 69 6d 65 20 6e 65 65 | 64 6e 27 74 20 77 6f 72 |time nee|dn't wor|
|00000c50| 72 79 20 61 62 6f 75 74 | 20 63 6f 6d 70 69 6c 69 |ry about| compili|
|00000c60| 6e 67 20 72 65 67 75 6c | 61 72 0d 65 78 70 72 65 |ng regul|ar.expre|
|00000c70| 73 73 69 6f 6e 73 2e 29 | 0d 5c 65 6e 64 7b 66 75 |ssions.)|.\end{fu|
|00000c80| 6e 63 64 65 73 63 7d 0d | 0d 5c 62 65 67 69 6e 7b |ncdesc}.|.\begin{|
|00000c90| 66 75 6e 63 64 65 73 63 | 7d 7b 73 65 74 5f 73 79 |funcdesc|}{set_sy|
|00000ca0| 6e 74 61 78 7d 7b 66 6c | 61 67 73 7d 0d 20 20 53 |ntax}{fl|ags}. S|
|00000cb0| 65 74 20 74 68 65 20 73 | 79 6e 74 61 78 20 74 6f |et the s|yntax to|
|00000cc0| 20 62 65 20 75 73 65 64 | 20 62 79 20 66 75 74 75 | be used| by futu|
|00000cd0| 72 65 20 63 61 6c 6c 73 | 20 74 6f 20 5c 63 6f 64 |re calls| to \cod|
|00000ce0| 65 7b 63 6f 6d 70 69 6c | 65 7d 2c 0d 20 20 5c 63 |e{compil|e},. \c|
|00000cf0| 6f 64 65 7b 6d 61 74 63 | 68 7d 20 61 6e 64 20 5c |ode{matc|h} and \|
|00000d00| 63 6f 64 65 7b 73 65 61 | 72 63 68 7d 2e 20 20 28 |code{sea|rch}. (|
|00000d10| 41 6c 72 65 61 64 79 20 | 63 6f 6d 70 69 6c 65 64 |Already |compiled|
|00000d20| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 6f 62 6a 65 | express|ion obje|
|00000d30| 63 74 73 0d 20 20 61 72 | 65 20 6e 6f 74 20 61 66 |cts. ar|e not af|
|00000d40| 66 65 63 74 65 64 2e 29 | 20 20 54 68 65 20 61 72 |fected.)| The ar|
|00000d50| 67 75 6d 65 6e 74 20 69 | 73 20 61 6e 20 69 6e 74 |gument i|s an int|
|00000d60| 65 67 65 72 20 77 68 69 | 63 68 20 69 73 20 74 68 |eger whi|ch is th|
|00000d70| 65 20 4f 52 20 6f 66 0d | 20 20 73 65 76 65 72 61 |e OR of.| severa|
|00000d80| 6c 20 66 6c 61 67 20 62 | 69 74 73 2e 20 20 54 68 |l flag b|its. Th|
|00000d90| 65 20 72 65 74 75 72 6e | 20 76 61 6c 75 65 20 69 |e return| value i|
|00000da0| 73 20 74 68 65 20 70 72 | 65 76 69 6f 75 73 20 76 |s the pr|evious v|
|00000db0| 61 6c 75 65 20 6f 66 0d | 20 20 74 68 65 20 73 79 |alue of.| the sy|
|00000dc0| 6e 74 61 78 20 66 6c 61 | 67 73 2e 20 20 4e 61 6d |ntax fla|gs. Nam|
|00000dd0| 65 73 20 66 6f 72 20 74 | 68 65 20 66 6c 61 67 73 |es for t|he flags|
|00000de0| 20 61 72 65 20 64 65 66 | 69 6e 65 64 20 69 6e 20 | are def|ined in |
|00000df0| 74 68 65 20 73 74 61 6e | 64 61 72 64 0d 20 20 6d |the stan|dard. m|
|00000e00| 6f 64 75 6c 65 20 5c 63 | 6f 64 65 7b 72 65 67 65 |odule \c|ode{rege|
|00000e10| 78 5f 73 79 6e 74 61 78 | 7d 3b 20 72 65 61 64 20 |x_syntax|}; read |
|00000e20| 74 68 65 20 66 69 6c 65 | 20 5c 66 69 6c 65 7b 72 |the file| \file{r|
|00000e30| 65 67 65 78 5f 73 79 6e | 74 61 78 2e 70 79 7d 20 |egex_syn|tax.py} |
|00000e40| 66 6f 72 0d 20 20 6d 6f | 72 65 20 69 6e 66 6f 72 |for. mo|re infor|
|00000e50| 6d 61 74 69 6f 6e 2e 0d | 5c 65 6e 64 7b 66 75 6e |mation..|\end{fun|
|00000e60| 63 64 65 73 63 7d 0d 0d | 5c 62 65 67 69 6e 7b 66 |cdesc}..|\begin{f|
|00000e70| 75 6e 63 64 65 73 63 7d | 7b 73 79 6d 63 6f 6d 70 |uncdesc}|{symcomp|
|00000e80| 7d 7b 70 61 74 74 65 72 | 6e 5c 6f 70 74 69 6f 6e |}{patter|n\option|
|00000e90| 61 6c 7b 5c 2c 20 74 72 | 61 6e 73 6c 61 74 65 7d |al{\, tr|anslate}|
|00000ea0| 7d 0d 54 68 69 73 20 69 | 73 20 6c 69 6b 65 20 5c |}.This i|s like \|
|00000eb0| 63 6f 64 65 7b 63 6f 6d | 70 69 6c 65 7d 2c 20 62 |code{com|pile}, b|
|00000ec0| 75 74 20 73 75 70 70 6f | 72 74 73 20 73 79 6d 62 |ut suppo|rts symb|
|00000ed0| 6f 6c 69 63 20 67 72 6f | 75 70 20 6e 61 6d 65 73 |olic gro|up names|
|00000ee0| 3a 20 69 66 20 61 0d 70 | 61 72 65 6e 74 68 65 73 |: if a.p|arenthes|
|00000ef0| 69 73 2d 65 6e 63 6c 6f | 73 65 64 20 67 72 6f 75 |is-enclo|sed grou|
|00000f00| 70 20 62 65 67 69 6e 73 | 20 77 69 74 68 20 61 20 |p begins| with a |
|00000f10| 67 72 6f 75 70 20 6e 61 | 6d 65 20 69 6e 20 61 6e |group na|me in an|
|00000f20| 67 75 6c 61 72 0d 62 72 | 61 63 6b 65 74 73 2c 20 |gular.br|ackets, |
|00000f30| 65 2e 67 2e 20 5c 63 6f | 64 65 7b 27 5c 65 28 3c |e.g. \co|de{'\e(<|
|00000f40| 69 64 3e 5b 61 2d 7a 5d | 5b 61 2d 7a 30 2d 39 5d |id>[a-z]|[a-z0-9]|
|00000f50| 2a 5c 65 29 27 7d 2c 20 | 74 68 65 20 67 72 6f 75 |*\e)'}, |the grou|
|00000f60| 70 20 63 61 6e 0d 62 65 | 20 72 65 66 65 72 65 6e |p can.be| referen|
|00000f70| 63 65 64 20 62 79 20 69 | 74 73 20 6e 61 6d 65 20 |ced by i|ts name |
|00000f80| 69 6e 20 61 72 67 75 6d | 65 6e 74 73 20 74 6f 20 |in argum|ents to |
|00000f90| 74 68 65 20 5c 63 6f 64 | 65 7b 67 72 6f 75 70 7d |the \cod|e{group}|
|00000fa0| 20 6d 65 74 68 6f 64 20 | 6f 66 0d 74 68 65 20 72 | method |of.the r|
|00000fb0| 65 73 75 6c 74 69 6e 67 | 20 63 6f 6d 70 69 6c 65 |esulting| compile|
|00000fc0| 64 20 72 65 67 75 6c 61 | 72 20 65 78 70 72 65 73 |d regula|r expres|
|00000fd0| 73 69 6f 6e 20 6f 62 6a | 65 63 74 2c 20 6c 69 6b |sion obj|ect, lik|
|00000fe0| 65 20 74 68 69 73 3a 0d | 5c 63 6f 64 65 7b 70 2e |e this:.|\code{p.|
|00000ff0| 67 72 6f 75 70 28 27 69 | 64 27 29 7d 2e 20 20 47 |group('i|d')}. G|
|00001000| 72 6f 75 70 20 6e 61 6d | 65 73 20 6d 61 79 20 63 |roup nam|es may c|
|00001010| 6f 6e 74 61 69 6e 20 61 | 6c 70 68 61 6e 75 6d 65 |ontain a|lphanume|
|00001020| 72 69 63 20 63 68 61 72 | 61 63 74 65 72 73 0d 61 |ric char|acters.a|
|00001030| 6e 64 20 5c 63 6f 64 65 | 7b 27 5f 27 7d 20 6f 6e |nd \code|{'_'} on|
|00001040| 6c 79 2e 0d 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |ly..\end|{funcdes|
|00001050| 63 7d 0d 0d 5c 62 65 67 | 69 6e 7b 65 78 63 64 65 |c}..\beg|in{excde|
|00001060| 73 63 7d 7b 65 72 72 6f | 72 7d 0d 20 20 45 78 63 |sc}{erro|r}. Exc|
|00001070| 65 70 74 69 6f 6e 20 72 | 61 69 73 65 64 20 77 68 |eption r|aised wh|
|00001080| 65 6e 20 61 20 73 74 72 | 69 6e 67 20 70 61 73 73 |en a str|ing pass|
|00001090| 65 64 20 74 6f 20 6f 6e | 65 20 6f 66 20 74 68 65 |ed to on|e of the|
|000010a0| 20 66 75 6e 63 74 69 6f | 6e 73 20 68 65 72 65 0d | functio|ns here.|
|000010b0| 20 20 69 73 20 6e 6f 74 | 20 61 20 76 61 6c 69 64 | is not| a valid|
|000010c0| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|000010d0| 69 6f 6e 20 28 65 2e 67 | 2e 2c 20 75 6e 6d 61 74 |ion (e.g|., unmat|
|000010e0| 63 68 65 64 20 70 61 72 | 65 6e 74 68 65 73 65 73 |ched par|entheses|
|000010f0| 29 20 6f 72 0d 20 20 77 | 68 65 6e 20 73 6f 6d 65 |) or. w|hen some|
|00001100| 20 6f 74 68 65 72 20 65 | 72 72 6f 72 20 6f 63 63 | other e|rror occ|
|00001110| 75 72 73 20 64 75 72 69 | 6e 67 20 63 6f 6d 70 69 |urs duri|ng compi|
|00001120| 6c 61 74 69 6f 6e 20 6f | 72 20 6d 61 74 63 68 69 |lation o|r matchi|
|00001130| 6e 67 2e 20 20 28 49 74 | 20 69 73 0d 20 20 6e 65 |ng. (It| is. ne|
|00001140| 76 65 72 20 61 6e 20 65 | 72 72 6f 72 20 69 66 20 |ver an e|rror if |
|00001150| 61 20 73 74 72 69 6e 67 | 20 63 6f 6e 74 61 69 6e |a string| contain|
|00001160| 73 20 6e 6f 20 6d 61 74 | 63 68 20 66 6f 72 20 61 |s no mat|ch for a|
|00001170| 20 70 61 74 74 65 72 6e | 2e 29 0d 5c 65 6e 64 7b | pattern|.).\end{|
|00001180| 65 78 63 64 65 73 63 7d | 0d 0d 5c 62 65 67 69 6e |excdesc}|..\begin|
|00001190| 7b 64 61 74 61 64 65 73 | 63 7d 7b 63 61 73 65 66 |{datades|c}{casef|
|000011a0| 6f 6c 64 7d 0d 41 20 73 | 74 72 69 6e 67 20 73 75 |old}.A s|tring su|
|000011b0| 69 74 61 62 6c 65 20 74 | 6f 20 70 61 73 73 20 61 |itable t|o pass a|
|000011c0| 73 20 5c 76 61 72 7b 74 | 72 61 6e 73 6c 61 74 65 |s \var{t|ranslate|
|000011d0| 7d 20 61 72 67 75 6d 65 | 6e 74 20 74 6f 0d 5c 63 |} argume|nt to.\c|
|000011e0| 6f 64 65 7b 63 6f 6d 70 | 69 6c 65 7d 20 74 6f 20 |ode{comp|ile} to |
|000011f0| 6d 61 70 20 61 6c 6c 20 | 75 70 70 65 72 20 63 61 |map all |upper ca|
|00001200| 73 65 20 63 68 61 72 61 | 63 74 65 72 73 20 74 6f |se chara|cters to|
|00001210| 20 74 68 65 69 72 20 6c | 6f 77 65 72 63 61 73 65 | their l|owercase|
|00001220| 0d 65 71 75 69 76 61 6c | 65 6e 74 73 2e 0d 5c 65 |.equival|ents..\e|
|00001230| 6e 64 7b 64 61 74 61 64 | 65 73 63 7d 0d 0d 5c 6e |nd{datad|esc}..\n|
|00001240| 6f 69 6e 64 65 6e 74 0d | 43 6f 6d 70 69 6c 65 64 |oindent.|Compiled|
|00001250| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00001260| 69 6f 6e 20 6f 62 6a 65 | 63 74 73 20 73 75 70 70 |ion obje|cts supp|
|00001270| 6f 72 74 20 74 68 65 73 | 65 20 6d 65 74 68 6f 64 |ort thes|e method|
|00001280| 73 3a 0d 0d 5c 72 65 6e | 65 77 63 6f 6d 6d 61 6e |s:..\ren|ewcomman|
|00001290| 64 7b 5c 69 6e 64 65 78 | 73 75 62 69 74 65 6d 7d |d{\index|subitem}|
|000012a0| 7b 28 72 65 67 65 78 20 | 6d 65 74 68 6f 64 29 7d |{(regex |method)}|
|000012b0| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|000012c0| 7d 7b 6d 61 74 63 68 7d | 7b 73 74 72 69 6e 67 5c |}{match}|{string\|
|000012d0| 6f 70 74 69 6f 6e 61 6c | 7b 5c 2c 20 70 6f 73 7d |optional|{\, pos}|
|000012e0| 7d 0d 20 20 52 65 74 75 | 72 6e 20 68 6f 77 20 6d |}. Retu|rn how m|
|000012f0| 61 6e 79 20 63 68 61 72 | 61 63 74 65 72 73 20 61 |any char|acters a|
|00001300| 74 20 74 68 65 20 62 65 | 67 69 6e 6e 69 6e 67 20 |t the be|ginning |
|00001310| 6f 66 20 5c 76 61 72 7b | 73 74 72 69 6e 67 7d 20 |of \var{|string} |
|00001320| 6d 61 74 63 68 0d 20 20 | 74 68 65 20 63 6f 6d 70 |match. |the comp|
|00001330| 69 6c 65 64 20 72 65 67 | 75 6c 61 72 20 65 78 70 |iled reg|ular exp|
|00001340| 72 65 73 73 69 6f 6e 2e | 20 20 52 65 74 75 72 6e |ression.| Return|
|00001350| 20 5c 63 6f 64 65 7b 2d | 31 7d 20 69 66 20 74 68 | \code{-|1} if th|
|00001360| 65 20 73 74 72 69 6e 67 | 0d 20 20 64 6f 65 73 20 |e string|. does |
|00001370| 6e 6f 74 20 6d 61 74 63 | 68 20 74 68 65 20 70 61 |not matc|h the pa|
|00001380| 74 74 65 72 6e 20 28 74 | 68 69 73 20 69 73 20 64 |ttern (t|his is d|
|00001390| 69 66 66 65 72 65 6e 74 | 20 66 72 6f 6d 20 61 20 |ifferent| from a |
|000013a0| 7a 65 72 6f 2d 6c 65 6e | 67 74 68 0d 20 20 6d 61 |zero-len|gth. ma|
|000013b0| 74 63 68 21 29 2e 0d 20 | 20 0d 20 20 54 68 65 20 |tch!).. | . The |
|000013c0| 6f 70 74 69 6f 6e 61 6c | 20 73 65 63 6f 6e 64 20 |optional| second |
|000013d0| 70 61 72 61 6d 65 74 65 | 72 20 5c 76 61 72 7b 70 |paramete|r \var{p|
|000013e0| 6f 73 7d 20 67 69 76 65 | 73 20 61 6e 20 69 6e 64 |os} give|s an ind|
|000013f0| 65 78 20 69 6e 20 74 68 | 65 20 73 74 72 69 6e 67 |ex in th|e string|
|00001400| 0d 20 20 77 68 65 72 65 | 20 74 68 65 20 73 65 61 |. where| the sea|
|00001410| 72 63 68 20 69 73 20 74 | 6f 20 73 74 61 72 74 3b |rch is t|o start;|
|00001420| 20 69 74 20 64 65 66 61 | 75 6c 74 73 20 74 6f 20 | it defa|ults to |
|00001430| 5c 63 6f 64 65 7b 30 7d | 2e 20 20 54 68 69 73 20 |\code{0}|. This |
|00001440| 69 73 20 6e 6f 74 0d 20 | 20 63 6f 6d 70 6c 65 74 |is not. | complet|
|00001450| 65 6c 79 20 65 71 75 69 | 76 61 6c 65 6e 74 20 74 |ely equi|valent t|
|00001460| 6f 20 73 6c 69 63 69 6e | 67 20 74 68 65 20 73 74 |o slicin|g the st|
|00001470| 72 69 6e 67 3b 20 74 68 | 65 20 5c 63 6f 64 65 7b |ring; th|e \code{|
|00001480| 27 5c 5e 27 7d 20 70 61 | 74 74 65 72 6e 0d 20 20 |'\^'} pa|ttern. |
|00001490| 63 68 61 72 61 63 74 65 | 72 20 6d 61 74 63 68 65 |characte|r matche|
|000014a0| 73 20 61 74 20 74 68 65 | 20 72 65 61 6c 20 62 65 |s at the| real be|
|000014b0| 67 69 6e 20 6f 66 20 74 | 68 65 20 73 74 72 69 6e |gin of t|he strin|
|000014c0| 67 20 61 6e 64 20 61 74 | 20 70 6f 73 69 74 69 6f |g and at| positio|
|000014d0| 6e 73 0d 20 20 6a 75 73 | 74 20 61 66 74 65 72 20 |ns. jus|t after |
|000014e0| 61 20 6e 65 77 6c 69 6e | 65 2c 20 6e 6f 74 20 6e |a newlin|e, not n|
|000014f0| 65 63 65 73 73 61 72 69 | 6c 79 20 61 74 20 74 68 |ecessari|ly at th|
|00001500| 65 20 69 6e 64 65 78 20 | 77 68 65 72 65 20 74 68 |e index |where th|
|00001510| 65 20 73 65 61 72 63 68 | 0d 20 20 69 73 20 74 6f |e search|. is to|
|00001520| 20 73 74 61 72 74 2e 0d | 5c 65 6e 64 7b 66 75 6e | start..|\end{fun|
|00001530| 63 64 65 73 63 7d 0d 0d | 5c 62 65 67 69 6e 7b 66 |cdesc}..|\begin{f|
|00001540| 75 6e 63 64 65 73 63 7d | 7b 73 65 61 72 63 68 7d |uncdesc}|{search}|
|00001550| 7b 73 74 72 69 6e 67 5c | 6f 70 74 69 6f 6e 61 6c |{string\|optional|
|00001560| 7b 5c 2c 20 70 6f 73 7d | 7d 0d 20 20 52 65 74 75 |{\, pos}|}. Retu|
|00001570| 72 6e 20 74 68 65 20 66 | 69 72 73 74 20 70 6f 73 |rn the f|irst pos|
|00001580| 69 74 69 6f 6e 20 69 6e | 20 5c 76 61 72 7b 73 74 |ition in| \var{st|
|00001590| 72 69 6e 67 7d 20 74 68 | 61 74 20 6d 61 74 63 68 |ring} th|at match|
|000015a0| 65 73 20 74 68 65 20 72 | 65 67 75 6c 61 72 0d 20 |es the r|egular. |
|000015b0| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 5c 63 6f 64 | express|ion \cod|
|000015c0| 65 7b 70 61 74 74 65 72 | 6e 7d 2e 20 20 52 65 74 |e{patter|n}. Ret|
|000015d0| 75 72 6e 20 5c 63 6f 64 | 65 7b 2d 31 7d 20 69 66 |urn \cod|e{-1} if|
|000015e0| 20 6e 6f 20 70 6f 73 69 | 74 69 6f 6e 20 69 6e 20 | no posi|tion in |
|000015f0| 74 68 65 0d 20 20 73 74 | 72 69 6e 67 20 6d 61 74 |the. st|ring mat|
|00001600| 63 68 65 73 20 74 68 65 | 20 70 61 74 74 65 72 6e |ches the| pattern|
|00001610| 20 28 74 68 69 73 20 69 | 73 20 64 69 66 66 65 72 | (this i|s differ|
|00001620| 65 6e 74 20 66 72 6f 6d | 20 61 20 7a 65 72 6f 2d |ent from| a zero-|
|00001630| 6c 65 6e 67 74 68 0d 20 | 20 6d 61 74 63 68 20 61 |length. | match a|
|00001640| 6e 79 77 68 65 72 65 21 | 29 2e 0d 20 20 0d 20 20 |nywhere!|).. . |
|00001650| 54 68 65 20 6f 70 74 69 | 6f 6e 61 6c 20 73 65 63 |The opti|onal sec|
|00001660| 6f 6e 64 20 70 61 72 61 | 6d 65 74 65 72 20 68 61 |ond para|meter ha|
|00001670| 73 20 74 68 65 20 73 61 | 6d 65 20 6d 65 61 6e 69 |s the sa|me meani|
|00001680| 6e 67 20 61 73 20 66 6f | 72 20 74 68 65 0d 20 20 |ng as fo|r the. |
|00001690| 5c 63 6f 64 65 7b 6d 61 | 74 63 68 7d 20 6d 65 74 |\code{ma|tch} met|
|000016a0| 68 6f 64 2e 0d 5c 65 6e | 64 7b 66 75 6e 63 64 65 |hod..\en|d{funcde|
|000016b0| 73 63 7d 0d 0d 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|000016c0| 64 65 73 63 7d 7b 67 72 | 6f 75 70 7d 7b 69 6e 64 |desc}{gr|oup}{ind|
|000016d0| 65 78 5c 2c 20 69 6e 64 | 65 78 5c 2c 20 2e 2e 2e |ex\, ind|ex\, ...|
|000016e0| 7d 0d 54 68 69 73 20 6d | 65 74 68 6f 64 20 69 73 |}.This m|ethod is|
|000016f0| 20 6f 6e 6c 79 20 76 61 | 6c 69 64 20 77 68 65 6e | only va|lid when|
|00001700| 20 74 68 65 20 6c 61 73 | 74 20 63 61 6c 6c 20 74 | the las|t call t|
|00001710| 6f 20 74 68 65 20 5c 63 | 6f 64 65 7b 6d 61 74 63 |o the \c|ode{matc|
|00001720| 68 7d 0d 6f 72 20 5c 63 | 6f 64 65 7b 73 65 61 72 |h}.or \c|ode{sear|
|00001730| 63 68 7d 20 6d 65 74 68 | 6f 64 20 66 6f 75 6e 64 |ch} meth|od found|
|00001740| 20 61 20 6d 61 74 63 68 | 2e 20 20 49 74 20 72 65 | a match|. It re|
|00001750| 74 75 72 6e 73 20 6f 6e | 65 20 6f 72 20 6d 6f 72 |turns on|e or mor|
|00001760| 65 0d 67 72 6f 75 70 73 | 20 6f 66 20 74 68 65 20 |e.groups| of the |
|00001770| 6d 61 74 63 68 2e 20 20 | 49 66 20 74 68 65 72 65 |match. |If there|
|00001780| 20 69 73 20 61 20 73 69 | 6e 67 6c 65 20 5c 76 61 | is a si|ngle \va|
|00001790| 72 7b 69 6e 64 65 78 7d | 20 61 72 67 75 6d 65 6e |r{index}| argumen|
|000017a0| 74 2c 0d 74 68 65 20 72 | 65 73 75 6c 74 20 69 73 |t,.the r|esult is|
|000017b0| 20 61 20 73 69 6e 67 6c | 65 20 73 74 72 69 6e 67 | a singl|e string|
|000017c0| 3b 20 69 66 20 74 68 65 | 72 65 20 61 72 65 20 6d |; if the|re are m|
|000017d0| 75 6c 74 69 70 6c 65 20 | 61 72 67 75 6d 65 6e 74 |ultiple |argument|
|000017e0| 73 2c 20 74 68 65 0d 72 | 65 73 75 6c 74 20 69 73 |s, the.r|esult is|
|000017f0| 20 61 20 74 75 70 6c 65 | 20 77 69 74 68 20 6f 6e | a tuple| with on|
|00001800| 65 20 69 74 65 6d 20 70 | 65 72 20 61 72 67 75 6d |e item p|er argum|
|00001810| 65 6e 74 2e 20 20 49 66 | 20 74 68 65 20 5c 76 61 |ent. If| the \va|
|00001820| 72 7b 69 6e 64 65 78 7d | 20 69 73 0d 7a 65 72 6f |r{index}| is.zero|
|00001830| 2c 20 74 68 65 20 63 6f | 72 72 65 73 70 6f 6e 64 |, the co|rrespond|
|00001840| 69 6e 67 20 72 65 74 75 | 72 6e 20 76 61 6c 75 65 |ing retu|rn value|
|00001850| 20 69 73 20 74 68 65 20 | 65 6e 74 69 72 65 20 6d | is the |entire m|
|00001860| 61 74 63 68 69 6e 67 20 | 73 74 72 69 6e 67 3b 20 |atching |string; |
|00001870| 69 66 0d 69 74 20 69 73 | 20 69 6e 20 74 68 65 20 |if.it is| in the |
|00001880| 69 6e 63 6c 75 73 69 76 | 65 20 72 61 6e 67 65 20 |inclusiv|e range |
|00001890| 5b 31 2e 2e 39 39 5d 2c | 20 69 74 20 69 73 20 74 |[1..99],| it is t|
|000018a0| 68 65 20 73 74 72 69 6e | 67 20 6d 61 74 63 68 69 |he strin|g matchi|
|000018b0| 6e 67 20 74 68 65 0d 74 | 68 65 20 63 6f 72 72 65 |ng the.t|he corre|
|000018c0| 73 70 6f 6e 64 69 6e 67 | 20 70 61 72 65 6e 74 68 |sponding| parenth|
|000018d0| 65 73 69 7a 65 64 20 67 | 72 6f 75 70 20 28 75 73 |esized g|roup (us|
|000018e0| 69 6e 67 20 74 68 65 20 | 64 65 66 61 75 6c 74 20 |ing the |default |
|000018f0| 73 79 6e 74 61 78 2c 0d | 67 72 6f 75 70 73 20 61 |syntax,.|groups a|
|00001900| 72 65 20 70 61 72 65 6e | 74 68 65 73 69 7a 65 64 |re paren|thesized|
|00001910| 20 75 73 69 6e 67 20 5c | 63 6f 64 65 7b 5c 5c 28 | using \|code{\\(|
|00001920| 7d 20 61 6e 64 20 5c 63 | 6f 64 65 7b 5c 5c 29 7d |} and \c|ode{\\)}|
|00001930| 29 2e 20 20 49 66 20 6e | 6f 0d 73 75 63 68 20 67 |). If n|o.such g|
|00001940| 72 6f 75 70 20 65 78 69 | 73 74 73 2c 20 74 68 65 |roup exi|sts, the|
|00001950| 20 63 6f 72 72 65 73 70 | 6f 6e 64 69 6e 67 20 72 | corresp|onding r|
|00001960| 65 73 75 6c 74 20 69 73 | 20 5c 63 6f 64 65 7b 4e |esult is| \code{N|
|00001970| 6f 6e 65 7d 2e 0d 0d 49 | 66 20 74 68 65 20 72 65 |one}...I|f the re|
|00001980| 67 75 6c 61 72 20 65 78 | 70 72 65 73 73 69 6f 6e |gular ex|pression|
|00001990| 20 77 61 73 20 63 6f 6d | 70 69 6c 65 64 20 62 79 | was com|piled by|
|000019a0| 20 5c 63 6f 64 65 7b 73 | 79 6d 63 6f 6d 70 7d 20 | \code{s|ymcomp} |
|000019b0| 69 6e 73 74 65 61 64 20 | 6f 66 0d 5c 63 6f 64 65 |instead |of.\code|
|000019c0| 7b 63 6f 6d 70 69 6c 65 | 7d 2c 20 74 68 65 20 5c |{compile|}, the \|
|000019d0| 76 61 72 7b 69 6e 64 65 | 78 7d 20 61 72 67 75 6d |var{inde|x} argum|
|000019e0| 65 6e 74 73 20 6d 61 79 | 20 61 6c 73 6f 20 62 65 |ents may| also be|
|000019f0| 20 73 74 72 69 6e 67 73 | 0d 69 64 65 6e 74 69 66 | strings|.identif|
|00001a00| 79 69 6e 67 20 67 72 6f | 75 70 73 20 62 79 20 74 |ying gro|ups by t|
|00001a10| 68 65 69 72 20 67 72 6f | 75 70 20 6e 61 6d 65 2e |heir gro|up name.|
|00001a20| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|00001a30| 0d 5c 6e 6f 69 6e 64 65 | 6e 74 0d 43 6f 6d 70 69 |.\noinde|nt.Compi|
|00001a40| 6c 65 64 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 |led regu|lar expr|
|00001a50| 65 73 73 69 6f 6e 73 20 | 73 75 70 70 6f 72 74 20 |essions |support |
|00001a60| 74 68 65 73 65 20 64 61 | 74 61 20 61 74 74 72 69 |these da|ta attri|
|00001a70| 62 75 74 65 73 3a 0d 0d | 5c 72 65 6e 65 77 63 6f |butes:..|\renewco|
|00001a80| 6d 6d 61 6e 64 7b 5c 69 | 6e 64 65 78 73 75 62 69 |mmand{\i|ndexsubi|
|00001a90| 74 65 6d 7d 7b 28 72 65 | 67 65 78 20 61 74 74 72 |tem}{(re|gex attr|
|00001aa0| 69 62 75 74 65 29 7d 0d | 0d 5c 62 65 67 69 6e 7b |ibute)}.|.\begin{|
|00001ab0| 64 61 74 61 64 65 73 63 | 7d 7b 72 65 67 73 7d 0d |datadesc|}{regs}.|
|00001ac0| 57 68 65 6e 20 74 68 65 | 20 6c 61 73 74 20 63 61 |When the| last ca|
|00001ad0| 6c 6c 20 74 6f 20 74 68 | 65 20 5c 63 6f 64 65 7b |ll to th|e \code{|
|00001ae0| 6d 61 74 63 68 7d 20 6f | 72 20 5c 63 6f 64 65 7b |match} o|r \code{|
|00001af0| 73 65 61 72 63 68 7d 20 | 6d 65 74 68 6f 64 20 66 |search} |method f|
|00001b00| 6f 75 6e 64 20 61 0d 6d | 61 74 63 68 2c 20 74 68 |ound a.m|atch, th|
|00001b10| 69 73 20 69 73 20 61 20 | 74 75 70 6c 65 20 6f 66 |is is a |tuple of|
|00001b20| 20 70 61 69 72 73 20 6f | 66 20 69 6e 64 69 63 65 | pairs o|f indice|
|00001b30| 73 20 63 6f 72 72 65 73 | 70 6f 6e 64 69 6e 67 20 |s corres|ponding |
|00001b40| 74 6f 20 74 68 65 0d 62 | 65 67 69 6e 6e 69 6e 67 |to the.b|eginning|
|00001b50| 20 61 6e 64 20 65 6e 64 | 20 6f 66 20 61 6c 6c 20 | and end| of all |
|00001b60| 70 61 72 65 6e 74 68 65 | 73 69 7a 65 64 20 67 72 |parenthe|sized gr|
|00001b70| 6f 75 70 73 20 69 6e 20 | 74 68 65 20 70 61 74 74 |oups in |the patt|
|00001b80| 65 72 6e 2e 20 20 49 6e | 64 69 63 65 73 0d 61 72 |ern. In|dices.ar|
|00001b90| 65 20 72 65 6c 61 74 69 | 76 65 20 74 6f 20 74 68 |e relati|ve to th|
|00001ba0| 65 20 73 74 72 69 6e 67 | 20 61 72 67 75 6d 65 6e |e string| argumen|
|00001bb0| 74 20 70 61 73 73 65 64 | 20 74 6f 20 5c 63 6f 64 |t passed| to \cod|
|00001bc0| 65 7b 6d 61 74 63 68 7d | 20 6f 72 0d 5c 63 6f 64 |e{match}| or.\cod|
|00001bd0| 65 7b 73 65 61 72 63 68 | 7d 2e 20 20 54 68 65 20 |e{search|}. The |
|00001be0| 30 2d 74 68 20 74 75 70 | 6c 65 20 67 69 76 65 73 |0-th tup|le gives|
|00001bf0| 20 74 68 65 20 62 65 67 | 69 6e 6e 69 6e 67 20 61 | the beg|inning a|
|00001c00| 6e 64 20 65 6e 64 20 6f | 72 20 74 68 65 0d 77 68 |nd end o|r the.wh|
|00001c10| 6f 6c 65 20 70 61 74 74 | 65 72 6e 2e 20 20 57 68 |ole patt|ern. Wh|
|00001c20| 65 6e 20 74 68 65 20 6c | 61 73 74 20 6d 61 74 63 |en the l|ast matc|
|00001c30| 68 20 6f 72 20 73 65 61 | 72 63 68 20 66 61 69 6c |h or sea|rch fail|
|00001c40| 65 64 2c 20 74 68 69 73 | 20 69 73 0d 5c 63 6f 64 |ed, this| is.\cod|
|00001c50| 65 7b 4e 6f 6e 65 7d 2e | 0d 5c 65 6e 64 7b 64 61 |e{None}.|.\end{da|
|00001c60| 74 61 64 65 73 63 7d 0d | 0d 5c 62 65 67 69 6e 7b |tadesc}.|.\begin{|
|00001c70| 64 61 74 61 64 65 73 63 | 7d 7b 6c 61 73 74 7d 0d |datadesc|}{last}.|
|00001c80| 57 68 65 6e 20 74 68 65 | 20 6c 61 73 74 20 63 61 |When the| last ca|
|00001c90| 6c 6c 20 74 6f 20 74 68 | 65 20 5c 63 6f 64 65 7b |ll to th|e \code{|
|00001ca0| 6d 61 74 63 68 7d 20 6f | 72 20 5c 63 6f 64 65 7b |match} o|r \code{|
|00001cb0| 73 65 61 72 63 68 7d 20 | 6d 65 74 68 6f 64 20 66 |search} |method f|
|00001cc0| 6f 75 6e 64 20 61 0d 6d | 61 74 63 68 2c 20 74 68 |ound a.m|atch, th|
|00001cd0| 69 73 20 69 73 20 74 68 | 65 20 73 74 72 69 6e 67 |is is th|e string|
|00001ce0| 20 61 72 67 75 6d 65 6e | 74 20 70 61 73 73 65 64 | argumen|t passed|
|00001cf0| 20 74 6f 20 74 68 61 74 | 20 6d 65 74 68 6f 64 2e | to that| method.|
|00001d00| 20 20 57 68 65 6e 20 74 | 68 65 0d 6c 61 73 74 20 | When t|he.last |
|00001d10| 6d 61 74 63 68 20 6f 72 | 20 73 65 61 72 63 68 20 |match or| search |
|00001d20| 66 61 69 6c 65 64 2c 20 | 74 68 69 73 20 69 73 20 |failed, |this is |
|00001d30| 5c 63 6f 64 65 7b 4e 6f | 6e 65 7d 2e 0d 5c 65 6e |\code{No|ne}..\en|
|00001d40| 64 7b 64 61 74 61 64 65 | 73 63 7d 0d 0d 5c 62 65 |d{datade|sc}..\be|
|00001d50| 67 69 6e 7b 64 61 74 61 | 64 65 73 63 7d 7b 74 72 |gin{data|desc}{tr|
|00001d60| 61 6e 73 6c 61 74 65 7d | 0d 54 68 69 73 20 69 73 |anslate}|.This is|
|00001d70| 20 74 68 65 20 76 61 6c | 75 65 20 6f 66 20 74 68 | the val|ue of th|
|00001d80| 65 20 5c 76 61 72 7b 74 | 72 61 6e 73 6c 61 74 65 |e \var{t|ranslate|
|00001d90| 7d 20 61 72 67 75 6d 65 | 6e 74 20 74 6f 0d 5c 63 |} argume|nt to.\c|
|00001da0| 6f 64 65 7b 72 65 67 65 | 78 2e 63 6f 6d 70 69 6c |ode{rege|x.compil|
|00001db0| 65 7d 20 74 68 61 74 20 | 63 72 65 61 74 65 64 20 |e} that |created |
|00001dc0| 74 68 69 73 20 72 65 67 | 75 6c 61 72 20 65 78 70 |this reg|ular exp|
|00001dd0| 72 65 73 73 69 6f 6e 20 | 6f 62 6a 65 63 74 2e 20 |ression |object. |
|00001de0| 20 49 66 0d 74 68 65 20 | 5c 76 61 72 7b 74 72 61 | If.the |\var{tra|
|00001df0| 6e 73 6c 61 74 65 7d 20 | 61 72 67 75 6d 65 6e 74 |nslate} |argument|
|00001e00| 20 77 61 73 20 6f 6d 69 | 74 74 65 64 20 69 6e 20 | was omi|tted in |
|00001e10| 74 68 65 20 5c 63 6f 64 | 65 7b 72 65 67 65 78 2e |the \cod|e{regex.|
|00001e20| 63 6f 6d 70 69 6c 65 7d | 0d 63 61 6c 6c 2c 20 74 |compile}|.call, t|
|00001e30| 68 69 73 20 69 73 20 5c | 63 6f 64 65 7b 4e 6f 6e |his is \|code{Non|
|00001e40| 65 7d 2e 0d 5c 65 6e 64 | 7b 64 61 74 61 64 65 73 |e}..\end|{datades|
|00001e50| 63 7d 0d 0d 5c 62 65 67 | 69 6e 7b 64 61 74 61 64 |c}..\beg|in{datad|
|00001e60| 65 73 63 7d 7b 67 69 76 | 65 6e 70 61 74 7d 0d 54 |esc}{giv|enpat}.T|
|00001e70| 68 65 20 72 65 67 75 6c | 61 72 20 65 78 70 72 65 |he regul|ar expre|
|00001e80| 73 73 69 6f 6e 20 70 61 | 74 74 65 72 6e 20 61 73 |ssion pa|ttern as|
|00001e90| 20 70 61 73 73 65 64 20 | 74 6f 20 5c 63 6f 64 65 | passed |to \code|
|00001ea0| 7b 63 6f 6d 70 69 6c 65 | 7d 20 6f 72 0d 5c 63 6f |{compile|} or.\co|
|00001eb0| 64 65 7b 73 79 6d 63 6f | 6d 70 7d 2e 0d 5c 65 6e |de{symco|mp}..\en|
|00001ec0| 64 7b 64 61 74 61 64 65 | 73 63 7d 0d 0d 5c 62 65 |d{datade|sc}..\be|
|00001ed0| 67 69 6e 7b 64 61 74 61 | 64 65 73 63 7d 7b 72 65 |gin{data|desc}{re|
|00001ee0| 61 6c 70 61 74 7d 0d 54 | 68 65 20 72 65 67 75 6c |alpat}.T|he regul|
|00001ef0| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 20 61 66 |ar expre|ssion af|
|00001f00| 74 65 72 20 73 74 72 69 | 70 70 69 6e 67 20 74 68 |ter stri|pping th|
|00001f10| 65 20 67 72 6f 75 70 20 | 6e 61 6d 65 73 20 66 6f |e group |names fo|
|00001f20| 72 20 72 65 67 75 6c 61 | 72 0d 65 78 70 72 65 73 |r regula|r.expres|
|00001f30| 73 69 6f 6e 73 20 63 6f | 6d 70 69 6c 65 64 20 77 |sions co|mpiled w|
|00001f40| 69 74 68 20 5c 63 6f 64 | 65 7b 73 79 6d 63 6f 6d |ith \cod|e{symcom|
|00001f50| 70 7d 2e 20 20 53 61 6d | 65 20 61 73 20 5c 63 6f |p}. Sam|e as \co|
|00001f60| 64 65 7b 67 69 76 65 6e | 70 61 74 7d 0d 6f 74 68 |de{given|pat}.oth|
|00001f70| 65 72 77 69 73 65 2e 0d | 5c 65 6e 64 7b 64 61 74 |erwise..|\end{dat|
|00001f80| 61 64 65 73 63 7d 0d 0d | 5c 62 65 67 69 6e 7b 64 |adesc}..|\begin{d|
|00001f90| 61 74 61 64 65 73 63 7d | 7b 67 72 6f 75 70 69 6e |atadesc}|{groupin|
|00001fa0| 64 65 78 7d 0d 41 20 64 | 69 63 74 69 6f 6e 61 72 |dex}.A d|ictionar|
|00001fb0| 79 20 67 69 76 69 6e 67 | 20 74 68 65 20 6d 61 70 |y giving| the map|
|00001fc0| 70 69 6e 67 20 66 72 6f | 6d 20 73 79 6d 62 6f 6c |ping fro|m symbol|
|00001fd0| 69 63 20 67 72 6f 75 70 | 20 6e 61 6d 65 73 20 74 |ic group| names t|
|00001fe0| 6f 20 6e 75 6d 65 72 69 | 63 61 6c 0d 67 72 6f 75 |o numeri|cal.grou|
|00001ff0| 70 20 69 6e 64 69 63 65 | 73 20 66 6f 72 20 72 65 |p indice|s for re|
|00002000| 67 75 6c 61 72 20 65 78 | 70 72 65 73 73 69 6f 6e |gular ex|pression|
|00002010| 73 20 63 6f 6d 70 69 6c | 65 64 20 77 69 74 68 20 |s compil|ed with |
|00002020| 5c 63 6f 64 65 7b 73 79 | 6d 63 6f 6d 70 7d 2e 0d |\code{sy|mcomp}..|
|00002030| 5c 63 6f 64 65 7b 4e 6f | 6e 65 7d 20 6f 74 68 65 |\code{No|ne} othe|
|00002040| 72 77 69 73 65 2e 0d 5c | 65 6e 64 7b 64 61 74 61 |rwise..\|end{data|
|00002050| 64 65 73 63 7d 0d | |desc}. | |
+--------+-------------------------+-------------------------+--------+--------+