SlideShare a Scribd company logo
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

JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
Jeff Fox
 
Json
JsonJson
Practical Object Oriented Models In Sql
Practical Object Oriented Models In SqlPractical Object Oriented Models In Sql
Practical Object Oriented Models In Sql
Karwin Software Solutions LLC
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and FunctionsJussi Pohjolainen
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
Matt Casto
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | Edureka
Edureka!
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Eran Zimbler
 
Finaal application on regular expression
Finaal application on regular expressionFinaal application on regular expression
Finaal application on regular expression
Gagan019
 
jQuery
jQueryjQuery
jQuery
Vishwa Mohan
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
Jacob Kaplan-Moss
 
Regex - Regular Expression Basics
Regex - Regular Expression BasicsRegex - Regular Expression Basics
Regex - Regular Expression Basics
Eterna Han Tsai
 
Json Tutorial
Json TutorialJson Tutorial
Json Tutorial
Napendra Singh
 
9 python data structure-2
9 python data structure-29 python data structure-2
9 python data structure-2
Prof. Dr. K. Adisesha
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
Luigi De Russis
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
Lovely Professional University
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
Alaref Abushaala
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
07 java collection
07 java collection07 java collection
07 java collection
Abhishek Khune
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in Python
Pooja B S
 
Heaps
HeapsHeaps

What's hot (20)

JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
Json
JsonJson
Json
 
Practical Object Oriented Models In Sql
Practical Object Oriented Models In SqlPractical Object Oriented Models In Sql
Practical Object Oriented Models In Sql
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
 
Introduction to Regular Expressions
Introduction to Regular ExpressionsIntroduction to Regular Expressions
Introduction to Regular Expressions
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | Edureka
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Finaal application on regular expression
Finaal application on regular expressionFinaal application on regular expression
Finaal application on regular expression
 
jQuery
jQueryjQuery
jQuery
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
Regex - Regular Expression Basics
Regex - Regular Expression BasicsRegex - Regular Expression Basics
Regex - Regular Expression Basics
 
Json Tutorial
Json TutorialJson Tutorial
Json Tutorial
 
9 python data structure-2
9 python data structure-29 python data structure-2
9 python data structure-2
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
07 java collection
07 java collection07 java collection
07 java collection
 
String Manipulation in Python
String Manipulation in PythonString Manipulation in Python
String Manipulation in Python
 
Heaps
HeapsHeaps
Heaps
 

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 beyond
Chip 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.5
Nont 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.26
Chanpen Thawornsak
 
งานนำเสนอ Linux
งานนำเสนอ  Linuxงานนำเสนอ  Linux
งานนำเสนอ Linux
jamiezaa123
 
Oss for-biz
Oss for-bizOss for-biz
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
 
Php & mysql
Php & mysqlPhp & mysql

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

Expresiones Regulares
Expresiones RegularesExpresiones Regulares
Expresiones Regulares
Juan Carlos Gonzales Vitte.
 
mhg
mhgmhg
slide share test
slide share testslide share test
slide share test
DreamMalar
 
Regular expressions quick reference
Regular expressions quick referenceRegular expressions quick reference
Regular expressions quick reference
jvinhit
 
An Introduction to Regular expressions
An Introduction to Regular expressionsAn Introduction to Regular expressions
An Introduction to Regular expressions
Yamagata Europe
 

Similar to Regex cheatsheet (20)

Regexps
RegexpsRegexps
Regexps
 
Expresiones Regulares
Expresiones RegularesExpresiones Regulares
Expresiones Regulares
 
mhg
mhgmhg
mhg
 
slide share test
slide share testslide share test
slide share test
 
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
 
test
testtest
test
 
test
testtest
test
 
qwdeqwe
qwdeqweqwdeqwe
qwdeqwe
 
Consent Decree Florida
 	Consent Decree Florida  	Consent Decree Florida
Consent Decree Florida
 
estset
estsetestset
estset
 
cross check
cross checkcross check
cross check
 

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