Home arrow ASP arrow Page 4 - The Complete Regular Expression Guide

The Complete Regular Expression Guide

Thought regular expressions were too tough to master? If so, think again! In this article Jan runs you through everything you need to know, no matter which programming language you use!

Author Info:
By: Jan Borsodi
Rating: 5 stars5 stars5 stars5 stars5 stars / 58
December 27, 2002
  1. · The Complete Regular Expression Guide
  2. · Usage
  3. · Assertions
  4. · Wildcards
  5. · Conclusion

print this article

The Complete Regular Expression Guide - Wildcards
(Page 4 of 5 )

For people who have some knowledge of wildcards, I will give you a brief explanation of how to convert them to regular expressions. A typical wildcard looks like this:


... and matches any text which end with .jpg. You can also specify brackets with characters, for example:


...matches any text which ends in .cpp or .hpp.

To really get to know regular expressions, I've left some commonly used expressions on this page. Study them, experiment with them and try to understand exactly what they accomplish.

Email validity will only match email addresses which are valid, for instance user@host.com:


Email validity #2 matches email addresses with a name in front, for instance "Joe Doe":

("?[a-zA-Z]+"?[ \t]*)+\<[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+\>

Protocol validity matches web based protocols such as htpp://, ftp:// or https://


C/C++ includes matches valid include statements in C/C++ files:

^#include[ \t]+[<"][^>"]+[">]

C++ end of line comments


Floating point numbers match simple floating point numbers such as 1.2 and 0.5:


Hexadecimal numbers match C/C++ style hex numbers such as 0xcafebabe:


There are several utilities that use regular expressions for data extraction, text validation, etc. I will leave you with brief descriptions of some of them.

Grep searches named input files for lines containing a match to the given pattern. It can also be used to find files that contain a specific pattern, for instance:

grep -E "cow|vache" * >/dev/null && echo "Found a cow"

This utility is rather common on Linux distributions, but if you don't have it you can grab a version on the GNU page.

A small tip is to enable extended regular expressions with the ĖE option. If you don't enable it, then a lot of the meta-characters explained earlier in this article won't work.

Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream. This utility is rather common on Linux distributions, but if you don't have it you can grab a version on the GNU page.

Gawk is the GNU Project's implementation of the AWK programming language. It conforms to the definition of the language in the POSIX 1003.2 command Language and utilities standard. This is utility is rather common on Linux distributions, but if you don't have it you can grab a version on the GNU page.

RegExplorer is a visual regular expression explorer. It allows for writing regular expressions and visually seeing matches, thus making regular expression much easier to write and maintain. You can grab a copy at the RegExplorer page.

Visual RegExp
This software will let you design your regexpís by letting you type the expression and visualize its effect on a sample piece of text. You can grab a copy at the Visual RegExp page.

Regexx is a complete regular expression solution for C++. It implements easy expression execution, global searching, replace with atom substitution, customized replaces, easy match and atom strings retrieving. Grab a copy at it's home page.
blog comments powered by Disqus

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials