Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
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))

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
Object Orientation and General technical topics module Q806
Regular Expression Cookbook
Exercises, examples and other material relating to training module Q806. This topic is presented on public course Regular Expressions

Related technical and longer articles
Regular Expressions in Java

Articles and tips on this subjectupdated
3788Getting more than a yes / no answer from a regular expression pattern match
Guy walks up to me in the street and asks "Could you direct me to the Town Centre?". So I answer him "yes, I could", and walk on. Does he thank me? No - he probably thinks "what a useless half answer" or "how rude can you be", even though I completely and correctly answered his question. It's sometimes ...
3218Matching a license plate or product code - Regular Expressions
Questions from my mailbox: 1. Regular expression to accept the following form of license plate numbers. Three letters followed by between 1 and 4 digits. 2. A regular expression to accept the following product codes: Between 1 and three characters (in capitals) followed by between one and three digits. OK ...
2804Regular Expression Myths
Does this look good to you?   /.*\S+[@]\S+.*/ It shows some regular expression myths that I would like to explode! Myth 1. If you want to match a specific character, you must put it in square brackets. WRONG ... Square Brackets are a grouping - if you're looking to match just a single specific ...
2727Making a Lua program run more than 10 times faster
I made an extraordinary claim on Thursday. One of my delegates had written a program that analyzed a huge data file in a Lua script, and it was taking over half an hour to run. "Give me five minutes, and I could have that running in less that five minutes" I claimed. It was all to do with pattern ...
2702First and last match with Regular Expressions
Conventional Wisdom says that it's pointless to start a regular expression with ".*" or ".+", as this is implied within a match - regular expression matches are looking for strings that are contained anyway: '/abc/' - contains abc '/.*abc/' - contains anything or nothing, followed by abc However - ...
2608Search and replace in Ruby - Ruby Regular Expressions
"If you want to replace one part of a string by another in Ruby, you can use the sub method on your string object. The first parameter you give to the method is the string you want to replace, and the second is the string you want to replace it by." OK - that's the easy bit ... but what if .... If ...
2563Efficient debugging of regular expressions
Are you a programmer? Have you ever spent *hours* looking for a very odd bug in your code that, when you find and fix it, turns out to have been so blindingly obvious that you ask "why sis it take me so LONG" ... and so does the boss! The good news is that - if the boss is a programmer - (s)he will ...
2165Making Regular Expressions easy to read and maintain
Have you ever seen a long regular expression made up of so many special characters that you can't read or maintain it very easily? Something like /\(\s*([A-Z]{4})\s+(\d+(?:\.\d*)?)\s*\/\s*(\d+(?:\.\d*)?)\s*\/\s*(\d+(?:\.\d*)?)\s*\)/ We offer a Regular Expression Course that will help you understand ...
1840Validating Credit Card Numbers
It's standard practise for on line bookings these days to take credit or debit card details as a booking security, and we're no exception at Well House Manor - our hotel for business visitors to Melksham, Wiltshire. There are very many security issues involved, and I am not going to describe what we ...
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, ...
1230Commenting a Perl Regular Expression
The x modifier on the end of a Perl regular expression causes all spaces in the regular expression to be treated as comments (rather than matching exactly). This means that you can lay out your regular expressions much more cleanly. And wherever you're allowed white space, you can add comments from ...
672Keeping your regular expressions simple
There's something macho about programmers when it comes to regular expressions - so often they'll try and do the whole job in a single regular expression when doing a two stage process is much more logical, much quicker in operation, and far easier to code. Take a requirement that came up this morning, ...
Examples from our training material
easier.py   making regular expressions easier to read [Python]
ex1.php   Regular Expressions in PHP - from simple yes/no to ancilliary responses
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
Options for caputured output
Matching the parts of the string you don't want
When to use .* on the start of the end of a match
Using Regular Expressions to handle numbers
Other Regular Expression engines - from vi to Expect
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 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., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.info/resources/Q806.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb