SlideShare uma empresa Scribd logo
1 de 1
Baixar para ler 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

Mais conteúdo relacionado

Mais procurados

Regular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsRegular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsDanny Bryant
 
Regex - Regular Expression Basics
Regex - Regular Expression BasicsRegex - Regular Expression Basics
Regex - Regular Expression BasicsEterna Han Tsai
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressionsBen Brumfield
 
A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)Imdadul Himu
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxShreyasLawand
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data AnalysisAndrew Henshaw
 
Strings in c
Strings in cStrings in c
Strings in cvampugani
 
Regex Presentation
Regex PresentationRegex Presentation
Regex Presentationarnolambert
 
Advanced regular expressions
Advanced regular expressionsAdvanced regular expressions
Advanced regular expressionsNeha Jain
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in pythonSantosh Verma
 
Python Dictionary
Python DictionaryPython Dictionary
Python DictionarySoba Arjun
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in pythonhydpy
 
Regular expression in javascript
Regular expression in javascriptRegular expression in javascript
Regular expression in javascriptToan Nguyen
 
Strings in Python
Strings in PythonStrings in Python
Strings in Pythonnitamhaske
 
Regular expression
Regular expressionRegular expression
Regular expressionRajon
 

Mais procurados (20)

Regular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular ExpressionsRegular Expressions 101 Introduction to Regular Expressions
Regular Expressions 101 Introduction to Regular Expressions
 
Regex - Regular Expression Basics
Regex - Regular Expression BasicsRegex - Regular Expression Basics
Regex - Regular Expression Basics
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data Analysis
 
Strings in c
Strings in cStrings in c
Strings in c
 
Regex Presentation
Regex PresentationRegex Presentation
Regex Presentation
 
Tries
TriesTries
Tries
 
Advanced regular expressions
Advanced regular expressionsAdvanced regular expressions
Advanced regular expressions
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in python
 
Python Dictionary
Python DictionaryPython Dictionary
Python Dictionary
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Array and string
Array and stringArray and string
Array and string
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Regular expression in javascript
Regular expression in javascriptRegular expression in javascript
Regular expression in javascript
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Python list
Python listPython list
Python list
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 
estset
estsetestset
estset
 
Ganesh added
Ganesh added Ganesh added
Ganesh added
 
test
testtest
test
 
om
omom
om
 
test
testtest
test
 

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