Training, Open Source computer languages

This is page http://www.wellho.net/regex/tcl.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

Tcl, Tcl/Tk and Expect regular expressions

Up to and including release 8.0 of Tcl, the built in regular expression handler was good but basic - it lacked some of the shortcuts that keep the specification of a complex match down to a practical size text string. As from release 8.1, Tcl was enhanced to support extended regular expressions to the POSIX standard. Since Tcl is often embedded within appliactions which are not frequently updated, you may well find that your embedded Tcl is limited to the basic set - check your version using the $tcl_version varlable.
Operator TypeExamplesDescription
Literal Characters
Match a character exactly
a A y 6 % @Letters, digits and many special
characters match exactly
\$ \^ \+ \\ \?Precede other special characters
with a \ to cancel their regex special meaning
\n \t \rLiteral new line, tab, return
\cJ \cGControl codes
\xa3Hex codes for any character
Anchors and assertions ^Starts with
$Ends with
Character groups
any 1 character from the group
[aAeEiou]any character listed from [ to ]
[^aAeEiou]any character except aAeEio or u
[a-fA-F0-9]any hex character (0 to 9 or a to f)
.any character at all
(not new line in some circumstances)
[[:space:]]any space character (space \n \r or \t)
from Tcl 8.1 only
[[:alpha:]]any letter
from Tcl 8.1 only
[[:digit:]]any digit
from Tcl 8.1 only
[^[:space:]]any character that is NOT a space
from Tcl 8.1 only
Counts
apply to previous element
+1 or more ("some")
*0 or more ("perhaps some")
?0 or 1 ("perhaps a")
{4}exactly 4
from Tcl 8.1 only
{4,}4 or more
from Tcl 8.1 only
{4,8}between 4 and 8
from Tcl 8.1 only
Add a ? after any count to turn it sparse (match as few as possible) rather than have it default to greedy
Alternation |either, or
Grouping ( )group for count and save to variable
(?: )group for count but do not save
The above list show the most commonly used elements of POSIX regular expressions, and is not exhaustive.

Back to Regular Expression Home Page
Jump to Elements of a regular expression
Order a Regular Expression Mousemat for £4.95 inclusive

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho