Version 9 of re_syntax

Updated 2008-07-23 21:49:27 by buchs

This man page describes the regular expression syntax supported within Tcl:

  http://www.purl.org/tcl/home/man/tcl8.5/TclCmd/re_syntax.htm 

Here are examples of more complex syntax of regular expressions Advanced Regular Expression Examples


If someone were so inclined, it would be useful to add, to this page, some examples of how to use some of the more complex regular expression syntax functions. They were - see above - buchs

For instance:

atom
a grouping of 0 or more characters which are to be treated as one entity by subsequent metacharacters, etc. If more than one character is to be included in an atom, then some sort of grouping syntax is needed.
bracket expression
aka a regular expression class, this text, enclosed like this - [ stuff ] - where stuff is one or more single characters. A regular expression of [a-z] means that the atom can be any ASCII lower case alphabetic character . A regular expression of [^a-z] means that the atom can be any ASCII character EXCEPT a lower case alphabetic character. The bracket expression can contain various ranges of characters.
branch
{ABC|DEF} indicates that either the atom ABC or the atom DEF should match.
escape
an escape is one of a small set of characters preceeded by \
metasyntax
a sequence of (?xyz) where xyz is one or more alphabetic characters affecting the rest of the regular expressions.

[NOTE: metasyntax is one place where a variety of examples would be useful!]

quantifier
A metacharacter appended to a regular expression atom to indicate the number of times that atom may exist.

Many threads in the comp.lang.tcl newsgroup have inspired wonderful instances of RE explication. Michael A. Cleverly, for example, wrote a delightful one: [L1 ] on "Extracting numbers from text strings, removing unwanted characters".