Tcl is a cross platform language with full unicode support.
Flexibility: redefine or enhance existing commands or write new commands.
Event driven programming: Event driven I/O and variable tracing.
Library Interface: It is very easy to integrate existing C libraries into Tcl and provide a Tcl interface to the C library. These interface "stubs" are not tied to any particular version of Tcl and will continue to work even after upgrading Tcl.
Tcl Interface: Tcl provides a complete API so you use the Tcl interpreter from within your C/Python/Ruby/Java/R program.
Another benefit from using braced expression strings is that the byte compiler usually can generate more efficient code (5 - 10x faster) from them.
References:
proc
Argument Expansion (section 5)
Dictionaries in Tcl are values that hold a mapping from arbitrary values to other arbitrary values. They were introduced in Tcl 8.5, though there are limited versions for (the now unsupported) Tcl 8.4. Dictionaries are syntactically the same as lists with even numbers of elements; the first pair of elements is the first key and value of the dictionary, the second pair is the second tuple.
Thus:
fox "quick brown" dogs "lazy"
is a valid dictionary. The same key can be multiple times, but it is exactly as if the latter's value was in the earlier's value; these are the same dictionary:
abcd {1 2 3} defg {2 3 4} abcd {3 4 5}
abcd {3 4 5} defg {2 3 4}
Whitespace is unimportant, just as with lists.
An important concept with dictionaries is iteration order; dictionaries try to use the key insertion order as their iteration order, though when you update the value for a key that already exists, you overwrite that key's value. New keys go on the end.
References: dict
This topic is not intended to discuss regular expressions themselves. There are many resources on the internet explaining regular expressions and tools to help build regular expressions.
This topic will try to cover the common switches and methods of using regular expressions in Tcl and some of the differences between Tcl and other regular expression engines.
Regular expressions are generally slow. The first question you should ask is "Do I really need a regular expression?". Only match what you want. If you don't need the other data, don't match it.
For the purposes of these regular expression examples, the -expanded switch will be used in order to be able to comment and explain the regular expression.