Exercises, examples and other material relating to training module Q805. This topic is presented on public course Regular Expressions
|Articles and tips on this subject||updated|
|3790||Solution looking for a problem? Lookahead and Lookbehind|
There are some things that it's just plain difficult to find good, practical examples to show delegates on training course. "Solutions looking for problems" I call them sometimes. And one such group are lookahead and lookbehind in regular expression.
However, I think I did a bit better yesterday ...
|3100||Looking ahead and behind in Regular Expressions - double matching|
Look-ahead and look-behind are a way of "double matching" in a regular expression. If you're at a certain point in the match and you think "the next bit should conform to xxx and at the same time it should conform to yyy" then you can describe xxx via a look-ahead, and follow that with matching yyy ...
|3089||Python regular expressions - repeating, splitting, lookahead and lookbehind|
If you're looking for part of a string that's repeated again later in the string, you can capture the first occurrence and then use a back reference (\1, \2 etc) to refer to "same again". In Python, you can also name the element that you want to repeat - examples [here].
If you have a number of fields ...
|2909||Be gentle rather than macho ... regular expression techniques|
Please don't be "macho" with your regular expressions.
You can write a very long and complex pattern to match something like a postcode or email address, but if you do, it's be hard to test, difficult to debug, and awkard to maintain. And to add insult to injury, it will probably run slower that the ...
|728||Looking ahead and behind in a Regular Expression|
Regular expressions in Perl and PHP include facilities called zero width assertions, zero width lookahead and lookbehinds. A case of jargon that looks almost calculated to confuse?
Zero width assertions are where a regular expression matches some sort of condition in the line, without actually consuming ...
Examples from our training material
|ahead.pl|| Checking if part of a string matches twice with look-ahead|
|ex3.php|| negative lookahead - example and alterative|
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
Sparse and greedy counts
Back Referencing and saved variables
Look ahead and look behind
Non capture brackets
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
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.