Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Tcl/Tk module T247
Advanced Regular Expressions
Exercises, examples and other material relating to training module T247. This topic is presented on public courses Learning to program in Tcl, Tcl Programming, Tcl Programming

Regular expressions are considerably enhanced in recent versions of Tcl, and this module, which assumes some prior knowledge of basic regular expressions, goes into advanced features such as groupings, sparse and greedy counts, and the Posix standard groups.

Related technical and longer articles
Pattern Matching - a primer on regular Expressions

Articles and tips on this subjectupdated
4205Regular Expression Substitution - Tcl
regexp matches regular expressions in TCL, and it will return the latest match into a series of variables if you specify their names. regsub matches and replaces... not quite such a common requirement, and perhaps something I haven't blogged about in the past.   set newstory [regsub blue $original ...
1412Sparse and Greedy matching - Tcl 8.4
Problem Analysis Once you have done a sparse or greedy count, all your following counts will also be sparse or greedy - this is a well documented bug in Tcl 8.4! Reminder ... .* is a greedy match - any character and AS MANY AS POSSIBLE .*? is a sparse match - any character but AS FEW AS POSSIBLE set ...
1613Regular expression for 6 digits OR 25 digits
I can write a regular expression to match ANY number of digits between 6 and 25 ... ^[[:digit:]]{6,25}$ but how would I write a regular expression to match either 6 digits or 25 digits, but no number in between? ^([[:digit:]]{6}|[[:digit:]]{25})$ (The regular expressions in this example are Tcl and ...
1410Tcl / regsub - changing a string and using interesting bits
Regexp matches a string to a regular expression, and regsub goes one further in that it replaces the found string with something else, saving the transformed output into a new variable. But what if I want the output pattern to include part of the string that was matched? I can refer to the "interesting ...
1336Ignore case in Regular Expression
Do you want to ignore case in a regular expression? There are a variety of ways of doing it ... depending on the language you're writing. Here are some hints: /abcd/i Perl - an i after the regular expression eregi PHP - use eregi rather than ereg re.I or re.IGNORECASE Python - extra parameters ...
1305Regular expressions made easy - building from components
There seems to be a certain macho desire in many programmer's minds to write a single complicated regular expression to match against an input line, ignorning the structured approach that everyone accepts quite cheerfully in almost every other case. Have a look at this Python line: wholeline = r"\d\d-...-\d\d\d\d\s+(\d\d):(\d\d):(\d\d.\d\d),\s+(-?\d+\.\d+),\s+(-?\d+\.\d+),(-?\d+\.\d+),\s+(-?\d+\.\d+),(-?\d+\.\d+),\s+(-?\d+\.\d+)" Impressive, ...
1195Regular Express Primer
Over the years I've been teaching people about Regular Expressions, I've learnt what does and doesn't work in such tuition. A casual question I saw yesterday got me writing, and I've just posted up a new technical article to the solution centre - see here (it will open in a separate window). It's ...
943Matching within multiline strings, and ignoring case in regular expressions
Regular Expressions are powerful matching tools and you can specify almost anything within them. But there are certain facilities that are naturally applied to the regular expression as a whole rather than to parts of the match, and there are specified in a different way in each language / implementation. For ...
Examples from our training material
T247.tcl   Tcl in use for CGI scripting
aretest   advanced regular expression match demo
blob   Progressive regsub examples
sparkle   Sparse v Greedy regular expressions
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
What are advanced regular expressions?.
The working of a regular expression.
The elements of a regular expression.
Literal characters.
Character groups.
A little more on regexp and regsub.
A further example.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Tcl/Tk, Expect,Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: 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

PAGE: http://www.wellho.net/resources/T247.html • PAGE BUILT: Mon Feb 8 18:55:24 2016 • BUILD SYSTEM: WomanWithCat