web blazonry web development scripts and tutorials Get best price on Unlocked Galaxy S10 Lite
   PHP       Name Generators       Perl       CSS       Javascript       Java       MySql       How Tos       Resources   

Perl Home

Perl Scripts
  Count Links
  Mail to MySQL
  ProcLog Files
  Search and Replace
  Site Monitor
  UnTabify

Perl Articles
  csv2htm Converter
  OLE Automation
  Regular Expressions
  SubDir Recursion

Perl Resources
  Regular Expressions Quick Reference
  Regular Expressions Examples
  Recommended Sites
  Bestselling Perl Books
  Free Perl Books (new)
  Free Python Books(new)

Bookmark and Share




Perl Regular Expressions Quick Reference

This page is a quick reference for Regular Expressions.

Modifiers
i case-insensitive pattern matching.
g global replace, or replace all
m Treat string as multiple lines. That is, change ``^'' and ``$'' from matching at only the very start or end of the string to the start or end of any line anywhere within the string
s Treat string as single line. That is, change ``.'' to match any character whatsoever, even a newline, which it normally would not match.
x Extend your pattern's legibility by permitting whitespace and comments.

Special Characters

The following should be escaped if you are trying to match that character

 \  ^  .  $  |  (  )  [  ]  *  +  ?  {  }  ,

Special Character Definitions

    \   Quote the next metacharacter
    ^   Match the beginning of the line
    .   Match any character (except newline)
    $   Match the end of the line (or before newline at the end)
    |   Alternation
    ()  Grouping
    []  Character class

    *      Match 0 or more times
    +      Match 1 or more times
    ?      Match 1 or 0 times
    {n}    Match exactly n times
    {n,}   Match at least n times
    {n,m}  Match at least n but not more than m times

More Special Characters

    \t          tab                   (HT, TAB)
    \n          newline               (LF, NL)
    \r          return                (CR)
    \f          form feed             (FF)
    \a          alarm (bell)          (BEL)
    \e          escape (think troff)  (ESC)
    \033        octal char (think of a PDP-11)
    \x1B        hex char
    \c[         control char
    \l          lowercase next char (think vi)
    \u          uppercase next char (think vi)
    \L          lowercase till \E (think vi)
    \U          uppercase till \E (think vi)
    \E          end case modification (think vi)
    \Q          quote (disable) pattern metacharacters till \E

Even More Special Characters

    \w  Match a "word" character (alphanumeric plus "_")
    \W  Match a non-word character
    \s  Match a whitespace character
    \S  Match a non-whitespace character
    \d  Match a digit character
    \D  Match a non-digit character
    \b  Match a word boundary
    \B  Match a non-(word boundary)
    \A  Match only at beginning of string
    \Z  Match only at end of string, or before newline at the end
    \z  Match only at end of string
    \G  Match only where previous m//g left off (works only with /g)

See also for more about regular expressions:

 

Newest Pages
Test Google Ads Ver. 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Popup Windows (JavaScript)
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)

Least Popular Pages
iNews Applet (Java)
Java Resources
Site Monitor (Perl)
PHP Resources
 
 

  privacy policy     ||     © 1997-2016. astonishinc.com   All Rights Reserved.