Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Pattern matching with "//"

Pattern matching with "//"

  • Perl invokes a powerful tool for pattern matching that gives the program great flexibility in controlling matches. In Perl, a string is matched by placing it between two slashes as follows:

    /[pattern_to_match]/ 
    

  • Thus, /eric/ matches for the string "eric". You may also match according to whole classes of characters using the square brackets ([]). The pattern match will then match against any of the characters in the class. For example, to match for any single even numbered digit, you could use the following match:

    /[02468]/ 
    

  • For classes including an entire range of characters, you may use the dash (-) to represent the list. Thus, the following matches any single lower case letter in the alphabet:

    /[a-z]/ 
    

  • Likewise, you may use the caret (^) character within the square brackets to match every character that is "not" in the class. The following matches any single character that is not a digit.

    /[^0-9]/ 
    

Additional Resources:

Regular Expressions
Table of Contents
Matching Operators


Up to => Home / Authoring / Scripting / Tutorial




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers