SlideShare a Scribd company logo
1 of 1
Download to read offline
Regular Expressions - Quick Reference Guide
Anchors                              Literal Characters
^
                                                                                                     Character group contents
        start of line
$       end of line                  Letters and digits match exactly             axB70              x          individual chars
b      word boundary                Some special characters match exactly        @-=%               x-y        character range
B      not at word boundary                                                                         [:class:]  posix char class
A      start of subject
                                     Escape other specials with backslash         .  $ [
G      first match in subject
                                                                                                     [^:class:] negated class
z      end of subject               Character Groups
Z      end of subject               Almost any character (usually not newline)   .                  Examples
        or before newline at end                                                                     [a-zA-Z0-9_]
                                     Lists and ranges of characters               [ ]
Non-printing characters              Any character except those listed            [^ ]               [[:alnum:]_]
a        alarm (BEL, hex 07)
cx       "control-x"
e        escape (hex 1B)            Counts (add ? for non-greedy)                                   Comments
f        formfeed (hex 0C)          0 or more ("perhaps some")                     *                (?#comment)
n        newline (hex 0A)           0 or 1 ("perhaps a")                           ?
r        carriage return (hex OD)
t                                   1 or more ("some")                             +                Conditional subpatterns
          tab (hex 09)
ddd      octal code ddd             Between "n" and "m" of                         {n,m}            (?(condition)yes-pattern)
xhh      hex code hh                Exactly "n", "n" or more                       {n}, {n,}        (?(condition)yes|no-pattern)
x{hhh..} hex code hhh..

Generic character types              Alternation                                                     Recursive patterns
d      decimal digit                Either/or                                       |               (?n)         Numbered
D      not a decimal digit                                                                          (?0) (?R)    Entire regex
s      whitespace character
S                                   Lookahead and Lookbehind                                        (?&name)     Named
        not a whitespace char
w      "word" character             Followed by                                    (?= )
W      "non-word" character         NOT followed by                                (?! )            Replacements
POSIX character classes              Following                                    (?<= )             $n   reference capture
alnum letters and digits             NOT following                                (?<! )
alpha  letters                                                                                       Case foldings
ascii  character codes 0-127
blank                                Grouping                                                        u   upper case next char
       space or tab only
cntrl  control characters            For capture and counts                       ( )                U   upper case following
digit  decimal digits                Non-capturing                                (?: )              l   lower case next char
graph  printing chars -space                                                                         L   lower case following
lower  lower case letters
                                     Named captures                               (?<name>       )
print  printing chars +space         Alternation                                                     E   end case folding
punct  printing chars -alnum         Back references
space white space                                                                                    Conditional insertions
upper
                                     Numbered                                     n gn g{n}
       upper case letters                                                                            (?n:insertion)
word   "word" characters             Relative                                     g{-n}
xdigit hexadecimal digits            Named                                        k<name>           (?n:insertion:otherwise)
                                                                                                       http://www.e-texteditor.com

More Related Content

What's hot

Inference on the Semantic Web
Inference on the Semantic WebInference on the Semantic Web
Inference on the Semantic WebMyungjin Lee
 
Introduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxIntroduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxpriyadharshini murugan
 
Hydra: A Vocabulary for Hypermedia-Driven Web APIs
Hydra: A Vocabulary for Hypermedia-Driven Web APIsHydra: A Vocabulary for Hypermedia-Driven Web APIs
Hydra: A Vocabulary for Hypermedia-Driven Web APIsMarkus Lanthaler
 
String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.Malek Sumaiya
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxShreyasLawand
 
Regular Expression (Regex) Fundamentals
Regular Expression (Regex) FundamentalsRegular Expression (Regex) Fundamentals
Regular Expression (Regex) FundamentalsMesut Günes
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide shareDevashish Kumar
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.bhavesh lande
 
Google Page Rank Algorithm
Google Page Rank AlgorithmGoogle Page Rank Algorithm
Google Page Rank AlgorithmOmkar Dash
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysisIffat Anjum
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prologHarry Potter
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back trackingTech_MX
 

What's hot (20)

Inference on the Semantic Web
Inference on the Semantic WebInference on the Semantic Web
Inference on the Semantic Web
 
CSS selectors
CSS selectorsCSS selectors
CSS selectors
 
push down automata
push down automatapush down automata
push down automata
 
Introduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxIntroduction to css & its attributes with syntax
Introduction to css & its attributes with syntax
 
Hydra: A Vocabulary for Hypermedia-Driven Web APIs
Hydra: A Vocabulary for Hypermedia-Driven Web APIsHydra: A Vocabulary for Hypermedia-Driven Web APIs
Hydra: A Vocabulary for Hypermedia-Driven Web APIs
 
String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.String Matching Finite Automata & KMP Algorithm.
String Matching Finite Automata & KMP Algorithm.
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
 
Regular Expression (Regex) Fundamentals
Regular Expression (Regex) FundamentalsRegular Expression (Regex) Fundamentals
Regular Expression (Regex) Fundamentals
 
Dom
Dom Dom
Dom
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
jQuery
jQueryjQuery
jQuery
 
Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.
 
Google Page Rank Algorithm
Google Page Rank AlgorithmGoogle Page Rank Algorithm
Google Page Rank Algorithm
 
Lecture 02 lexical analysis
Lecture 02 lexical analysisLecture 02 lexical analysis
Lecture 02 lexical analysis
 
Functions in javascript
Functions in javascriptFunctions in javascript
Functions in javascript
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 

Viewers also liked

CloudStack 4.1, 4.2 and beyond
CloudStack 4.1, 4.2 and beyondCloudStack 4.1, 4.2 and beyond
CloudStack 4.1, 4.2 and beyondChip Childers
 
MySQL Multi-Master Replication Using Tungsten Replicator 2.0.5
MySQL Multi-Master Replication Using Tungsten Replicator 2.0.5MySQL Multi-Master Replication Using Tungsten Replicator 2.0.5
MySQL Multi-Master Replication Using Tungsten Replicator 2.0.5Nont Banditwong
 
การประมูลหมายเลขทะเบียนรถ
การประมูลหมายเลขทะเบียนรถการประมูลหมายเลขทะเบียนรถ
การประมูลหมายเลขทะเบียนรถNont Banditwong
 
Regular expressions-cheat-sheet-v2
Regular expressions-cheat-sheet-v2Regular expressions-cheat-sheet-v2
Regular expressions-cheat-sheet-v2Nont Banditwong
 
Smart Industry Newsletter Vol.26
Smart Industry Newsletter Vol.26Smart Industry Newsletter Vol.26
Smart Industry Newsletter Vol.26Chanpen Thawornsak
 
งานนำเสนอ Linux
งานนำเสนอ  Linuxงานนำเสนอ  Linux
งานนำเสนอ Linuxjamiezaa123
 
Hacking apache cloud stack
Hacking apache cloud stackHacking apache cloud stack
Hacking apache cloud stackMurali Reddy
 
The Future of Apache CloudStack (Not So Cloudy) (Collab 2012)
The Future of Apache CloudStack (Not So Cloudy) (Collab 2012)The Future of Apache CloudStack (Not So Cloudy) (Collab 2012)
The Future of Apache CloudStack (Not So Cloudy) (Collab 2012)Chiradeep Vittal
 

Viewers also liked (11)

CloudStack 4.1, 4.2 and beyond
CloudStack 4.1, 4.2 and beyondCloudStack 4.1, 4.2 and beyond
CloudStack 4.1, 4.2 and beyond
 
MySQL Multi-Master Replication Using Tungsten Replicator 2.0.5
MySQL Multi-Master Replication Using Tungsten Replicator 2.0.5MySQL Multi-Master Replication Using Tungsten Replicator 2.0.5
MySQL Multi-Master Replication Using Tungsten Replicator 2.0.5
 
การประมูลหมายเลขทะเบียนรถ
การประมูลหมายเลขทะเบียนรถการประมูลหมายเลขทะเบียนรถ
การประมูลหมายเลขทะเบียนรถ
 
Svn workflow
Svn workflowSvn workflow
Svn workflow
 
Regular expressions-cheat-sheet-v2
Regular expressions-cheat-sheet-v2Regular expressions-cheat-sheet-v2
Regular expressions-cheat-sheet-v2
 
Smart Industry Newsletter Vol.26
Smart Industry Newsletter Vol.26Smart Industry Newsletter Vol.26
Smart Industry Newsletter Vol.26
 
งานนำเสนอ Linux
งานนำเสนอ  Linuxงานนำเสนอ  Linux
งานนำเสนอ Linux
 
Oss for-biz
Oss for-bizOss for-biz
Oss for-biz
 
Hacking apache cloud stack
Hacking apache cloud stackHacking apache cloud stack
Hacking apache cloud stack
 
The Future of Apache CloudStack (Not So Cloudy) (Collab 2012)
The Future of Apache CloudStack (Not So Cloudy) (Collab 2012)The Future of Apache CloudStack (Not So Cloudy) (Collab 2012)
The Future of Apache CloudStack (Not So Cloudy) (Collab 2012)
 
Php & mysql
Php & mysqlPhp & mysql
Php & mysql
 

Similar to Regex cheatsheet (20)

Regexps
RegexpsRegexps
Regexps
 
Expresiones Regulares
Expresiones RegularesExpresiones Regulares
Expresiones Regulares
 
slide share test
slide share testslide share test
slide share test
 
mhg
mhgmhg
mhg
 
Regular expressions quick reference
Regular expressions quick referenceRegular expressions quick reference
Regular expressions quick reference
 
An Introduction to Regular expressions
An Introduction to Regular expressionsAn Introduction to Regular expressions
An Introduction to Regular expressions
 
test vedio
test vediotest vedio
test vedio
 
qwdeqwe
qwdeqweqwdeqwe
qwdeqwe
 
Added to test pdf
Added to test pdf Added to test pdf
Added to test pdf
 
added for test
added for test added for test
added for test
 
ganesh testing
ganesh testing ganesh testing
ganesh testing
 
now its pdf
now its pdfnow its pdf
now its pdf
 
fghfghf
fghfghffghfghf
fghfghf
 
The hindu
The hinduThe hindu
The hindu
 
Video added by Normal user
Video added by Normal user Video added by Normal user
Video added by Normal user
 
Added to test pdf
Added to test pdf Added to test pdf
Added to test pdf
 
dasdasd
dasdasddasdasd
dasdasd
 
estset
estsetestset
estset
 
1377874234 eeeeeeeeeeeeeeeor more file
1377874234 eeeeeeeeeeeeeeeor more file1377874234 eeeeeeeeeeeeeeeor more file
1377874234 eeeeeeeeeeeeeeeor more file
 
Ganesh added
Ganesh added Ganesh added
Ganesh added
 

Regex cheatsheet

  • 1. Regular Expressions - Quick Reference Guide Anchors Literal Characters ^ Character group contents start of line $ end of line Letters and digits match exactly axB70 x individual chars b word boundary Some special characters match exactly @-=% x-y character range B not at word boundary [:class:] posix char class A start of subject Escape other specials with backslash . $ [ G first match in subject [^:class:] negated class z end of subject Character Groups Z end of subject Almost any character (usually not newline) . Examples or before newline at end [a-zA-Z0-9_] Lists and ranges of characters [ ] Non-printing characters Any character except those listed [^ ] [[:alnum:]_] a alarm (BEL, hex 07) cx "control-x" e escape (hex 1B) Counts (add ? for non-greedy) Comments f formfeed (hex 0C) 0 or more ("perhaps some") * (?#comment) n newline (hex 0A) 0 or 1 ("perhaps a") ? r carriage return (hex OD) t 1 or more ("some") + Conditional subpatterns tab (hex 09) ddd octal code ddd Between "n" and "m" of {n,m} (?(condition)yes-pattern) xhh hex code hh Exactly "n", "n" or more {n}, {n,} (?(condition)yes|no-pattern) x{hhh..} hex code hhh.. Generic character types Alternation Recursive patterns d decimal digit Either/or | (?n) Numbered D not a decimal digit (?0) (?R) Entire regex s whitespace character S Lookahead and Lookbehind (?&name) Named not a whitespace char w "word" character Followed by (?= ) W "non-word" character NOT followed by (?! ) Replacements POSIX character classes Following (?<= ) $n reference capture alnum letters and digits NOT following (?<! ) alpha letters Case foldings ascii character codes 0-127 blank Grouping u upper case next char space or tab only cntrl control characters For capture and counts ( ) U upper case following digit decimal digits Non-capturing (?: ) l lower case next char graph printing chars -space L lower case following lower lower case letters Named captures (?<name> ) print printing chars +space Alternation E end case folding punct printing chars -alnum Back references space white space Conditional insertions upper Numbered n gn g{n} upper case letters (?n:insertion) word "word" characters Relative g{-n} xdigit hexadecimal digits Named k<name> (?n:insertion:otherwise) http://www.e-texteditor.com