spacer

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

home / experts / javascript / column5


Unix Regular Expressions

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

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