re_syntax(3tcl) Tcl Built-In Commands re_syntax(3tcl) ______________________________________________________________________________ NAME re_syntax - Tcl ______________________________________________________________________________ DESCRIPTION (regular expression ) RE DIFFERENT FLAVORS OF REs ("RE") POSIX (flavor): RE(``EREs'')RE(``BREs'')ERE egrep BRE ed RE(``AREs'') ERE grep BRE -E ERE egrep fgrep grep edsed BRElexAWK ERE ARE BRE (backward)POSIX ERE ARE ERE ARE REGULAR EXPRESSION SYNTAX Tcl Henry Spencer POSIX 1003.2 () Perl5 ( Henry!) Perl5 Henry Spencer ARE `|'(branch)() (constraint)(quantified atom)()() (quantifier) : * + ? {m} m {m,} m {m,n} m n ()m n *? +? ?? {m}? {m,}? {m,n}? (non-greedy) (MATCHING ) { } (bound) m n 0 255(0 255) : (re) ( re ) re () ab* a b b* a(b)* a b ab (ab)* (?:re) ("") () () (?:) [chars] (bracket expression) chars ( BRACKET EXPRESSIONS ) . \k ( k alphanumeric ())\\ \c ( c alphanumeric ()) (escape)( ARE)ESCAPES ) { `{'() x x (constraint) ESCAPES ^ $ (?=re) (positive lookahead) ( ARE) re (?!re) (negative lookahead) ( ARE) re () RE `\'. BRACKET EXPRESSIONS `[]'()"^"() `-'(collating sequence)()[0-9] ASCII a-c-e -- (locale) LC_COLLATE -- LC_COLLATE ] - [. .] ()(`^')( ARE) `\fR'`-' - ( ARE) `\' [ () [. .] (collating element)() ()| ^ | !| (Tcl | )| ch | RE [[.ch.]]*c ( c ch) | `chchcc'5 [^c]b | `chb'( [^c] ch) [= =] equivalence class (`[.'`.]') o ^ `[[=o=]]'`[[=^=]]'`[o^]' (Tcl Unicode | )| [: :] character class (!): alpha upper lower digit xdigit alnum alphanumeric () print alphanumeric ( alnum) blank tab space punct graph cntrl (Tcl | Unicode ) : [[:<:]] [[:>:]] alnum (_)ARE () ESCAPES ( ARE) \ : (entry) ARE alphanumeric \ ERE : alphanumeric \ \ ( ERE ARE ) (Character-entry escapes) ( ARE) RE : \a () C \b C \B \ \cX ( X ) 5 X 5 \e `ESC' 033 \f C \n C \r C \t tab C \uwxyz ( wxyz ) Unicode U+wxyz \Ustuvwxyz ( stuvwxyz ) 32 Unicode \v tab C \xhhh ( hhh ) 0xhhh () \0 0 \xy ( xy ()) 0xy \xyz ( xyz ()) 0xyz `0'-`9', `a'-`f', `A'-`F'. `0'-`7'. \135 ASCII ] \135 ( C )( (quadrupling)) `\' Class-shorthand escapes ( ARE) : \d [[:digit:]] \s [[:space:]] \w [[:alnum:]_] () \D [^[:digit:]] \S [^[:space:]] \W [^[:alnum:]_] () W`\d', `\s', `\w' `\D', `\S', `\W' ([a-| c[:digit:]] [a-c\d] [a-c^[:digit:]] [a-c\D] | ) constraint escape (AREs only) : \A ( `^' MATCHING ) \m \M \y \Y \Z ( `$' MATCHING ) \m ( m )back reference \mnn ( m nn mnn ) [[:<:]] [[:>:]] alnum (_) ( ARE) () ([bc])\1 bb cc `bc' RE () BRE ERE ^(.*)\1$ (a)*\1 a(a)(b)\1 aba(a)(b)\2 abb(a(b))\1 abab(a(b))\2 abb(a)\1 a{2,2} () METASYNTAX RE (director) RE `***:' RE ARE RE `***=' RE ARE embedded options : (?xyz) ( xyz ) RE : b RE BRE c () e RE ERE i ( MATCHING ) m n n ( MATCHING ) p ( MATCHING ) q RE ( ``quoted'') s () t () w ( ``weird'') ( MATCHING ) x () ) ARE () RE RE -expanded ARE x # ( RE ) RE : `\' `#' `#' ARE `(?:' `\(' blanktab | ARE `(?#ttt)' ( ttt `)' ) `(?:' ( ***= ) RE MATCHING XBD RE RE "": RE bb* abbbc 24 RE (wee|week)(knights|night) weeknights 10 (against) abcdef RE (.*).* , (1) abcdef bc RE (a*)* (1) ()acdacaaa (ac*)c*d[ac]*1 acdacaaa ( 1=a) (ac*) 1=ac (acdac)(): RE RE RE RE (a.*b)(a.*b) accbaccccb RE RE RE(preference): RE RE () {m} {m}? ()( {m,n} m n) ( {m,n}? m n ) | RE RE RE {1,1} {1,1}? RE bb* `abbbc' (week|wee)(night|knights) `weeknights'10(against) abc (.*).* bc (a*)* RE x `[xX]'[x] [xX] [^x] `[^xX]' . ^ ( RE ) ^ $ ARE [u548C] [u7EE7] . ^ `$' ^ $ . LIMITS AND COMPATIBILITY RE 256 RE POSIX RE ARE POSIX ERE \ ARE POSIX ERE *** BRE ERE POSIX ARE Perl Perl `\b'`\B' RE / beta RE () Henry Spencer 1986 regexp ( Tcl 8.1 ) ERE regexp ERE ( RRE) ARE : In roughly increasing order of significance: ARE \ RRE RRE ARE { RRE { ARE `[]' \ `[]' \ `\\' RRE [] `\\' \ ARE RE RRE( RRE (ARE )) BASIC REGULAR EXPRESSIONS BRE ERE `|', `+', ? \{ `\}', { } \( `\)', ( ) RE ^ RE $ RE * ( `^' ) \< \> [[:<:]] [[:>:]] SEE ALSO RegExp(3), regexp(n), regsub(n), lsearch(n), switch(n), text(n) KEYWORDS match, regular expression, string [] [] 2001/10/26 Linux man : http://cmpp.linuxforum.net man man https://github.com/man-pages-zh/manpages- zh Tcl 8.1 re_syntax(3tcl)