spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column5


Unix Regular Expressions

Developer News
Mozilla's Ubquity Mashup: For The Masses?
iPhone Users Just Want to Have Fun
Oops! I Fixed the Linux Kernel

What are RegExps?

RegExps, shorthand for regular expressions, are used in pattern matching and substitution operators. Regular expressions are actually a grammer for a little language. The regular expression interpreter (which we'll call the Engine) takes your grammer and compares it with the string you're doing pattern matching on. The Engine then returns a Boolean value, which depends on whether or not the string can be parsed as a sentence of your little language.

A regular expression is really just a sequence or a pattern of characters that is matched against a string of text when performing searches and replacements. A simple regular expression consists of a single character or a set of characters that matches itself.

Regexps are a very powerful tool. They pack a lot of meaning into a short space. Every single character in a regular expression has a special meaning. I once wasted several hours trying to fix a Perl script, only to find out later that I had forgotten a little "?", somewhere in one of the regular expressions I had constructed.

Many tasks can be done with regular expressions. The most common one is to find out whether a given string matches a particular pattern. You can also find out where the matching substring is located within the string. You can use a substitution command to replace matching sections with another string of your choice. The split() operator returns an array of all substrings your pattern did not match.

Don't worry if you still don't quite understand what regexps are. You'll soon become a regular expression expert.

http://www.internet.com



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Performance Optimizations for High Speed JavaScript · Advanced Web Performance Optimization · Simple Comments Meets OpenID
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Extending Telephony: VoIP Call Recording for Business · U-Verse for Business Has Wi-Fi Perks · Lian-Li Launches New Power Supply Line, Rack Mount Kit and Fan Blower

Created: October 23, 1997, 1997
Revised: December 4, 1997
URL: http://www.webreference.com/js/column5/regular.html