Home arrow Site Administration arrow Page 2 - So What's A $#!%% Regular Expression, Anyway?!

Ranging Far And Wide... - Administration

Regular expressions are one of the most powerful tools in the arsenal of any *NIX programmer. This article offers insights into what they are, how to go about constructing them, and how to add them to your Perl, PHP and JavaScript programs.

  1. So What's A $#!%% Regular Expression, Anyway?!
  2. Ranging Far And Wide...
  3. How To Say "Ummmm...." In Three Different Languages
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 5
April 12, 2000

print this article


Just as you can specify a range for the number of characters to be matched, you can also specify a range of characters. For example, the range

would match a single instance of all upper-case alphabetic characters, while

would match all lowercase letters, and

would match all numbers between 0 and 9.

Using these three ranges, it's pretty easy to create a regular expression to match an alphanumeric field.

would match a string that was purely alphanumeric in nature, like "aB0" - although not "abc". Note the parentheses around the patterns - contrary to what you might think, these are not there purely to confuse you; they come in handy when grouping sections of a regular expression together.

Choice is very important when building regular expressions - as in most other languages, it's possible to use the pipe [|] operator to indicate multiple options in a regex. For example,

would match any one of the three strings "to", "too" and "2". As you can imagine, this comes in pretty useful when building expressions that have many possible variants.

You can also invert the regular sense of a regular expression with the negation operator, represented by a caret [^] - so the pattern

would match everything but that which appears in the expression - namely, everything except the letters "A", "B" and "C". Note how the caret, when used in a bracketed expression, is used to invert the match; this behaviour is different from when it is used outside a bracketed expression, where it serves as a pattern anchor.

>>> More Site Administration Articles          >>> More By Vikram Vaswani and Harish Kamath, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates


Dev Shed Tutorial Topics: