Administration
  Home arrow Administration arrow Page 2 - So What's A $#!%% Regular Expression, ...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ADMINISTRATION

So What's A $#!%% Regular Expression, Anyway?!
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2000-04-12

    Table of Contents:
  • So What's A $#!%% Regular Expression, Anyway?!
  • Ranging Far And Wide...
  • How To Say "Ummmm...." In Three Different Languages

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    So What's A $#!%% Regular Expression, Anyway?! - Ranging Far And Wide...
    (Page 2 of 3 )

    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

    /[A-Z]/
    would match a single instance of all upper-case alphabetic characters, while

    /[a-z]/
    would match all lowercase letters, and

    /[0-9]/
    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.

    /([a-z][A-Z][0-9])+/
    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,

    /to|too|2/
    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

    /[^A-C]/
    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 Administration Articles
    More By Vikram Vaswani and Harish Kamath, (c) Melonfire


     

       

    ADMINISTRATION ARTICLES

    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization
    - Advanced Concepts on Dealing with Files and ...
    - Dealing with Files and Filesystems
    - More Hacks for the User Environment in BSD
    - Personalizing the User Environment in BSD
    - Customizing the User Environment in BSD

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway