SlideShare a Scribd company logo
Use To match any character
[set] In that set
[^set] Not in that set
[a–z] In the a-z range
[^a–z] Not in the a-z range
. Any except n (new line)
char Escaped special character
Use To match Unicode
t Horizontal tab u0009
v Vertical tab u000B
b Backspace u0008
e Escape u001B
r Carriage return u000D
f Form feed u000C
n New line u000A
a Bell (alarm) u0007
c char ASCII control
character

Use To match character with
octal 2-3 digit octal character code
x hex 2-digit hex character code
u hex 4-digit hex character code
Use To match character
p{ctgry} In that Unicode category or block
P{ctgry} Not in that Unicode category or
block
w Word character
W Non-word character
d Decimal digit
D Not a decimal digit
s White-space character
S Non-white-space char
Greedy Lazy Matches
* *? 0 or more times
+ +? 1 or more times
? ?? 0 or 1 time
{n} {n}? Exactly n times
{n,} {n,}? At least n times
{n,m} {n,m}? From n to m times
Use To specify position
^ At start of string or line
A At start of string
z At end of string
Z At end (or before n at end) of string
$ At end (or before n at end) of string
or line
G Where previous match ended
b On word boundary
B Not on word boundary
Use To define
(exp) Indexed group
(?<name>exp) Named group
(?<name1-
name2>exp)
Balancing group
(?:exp) Noncapturing group
(?=exp) Zero-width positive
lookahead
(?!exp) Zero-width negative
lookahead
(?<=exp) Zero-width positive
lookbehind
(?<!exp) Zero-width negative
lookbehind
(?>exp) Non-backtracking (greedy)
Option Effect on match
i Case-insensitive
m Multiline mode
n Explicit (named)
s Single-line mode
x Ignore white space
Use To
(?imnsx-
imnsx)
Set or disable the specified
options
(?imnsx-
imnsx:exp)
Set or disable the specified
options within the
expression
June 2014
 2014 Microsoft. All rights reserved.
Use To match
n Indexed group
k<name> Named group
Use To match
a |b Either a or b
(?(exp)
yes | no)
yes if exp is matched
no if exp isn't matched
(?(name)
yes | no)
yes if name is matched
no if name isn't matched
Use To substitute
$n Substring matched by group
number n
${name} Substring matched by group
name
$$ Literal $ character
$& Copy of whole match
$` Text before the match
$' Text after the match
$+ Last captured group
$_ Entire input string
Use To
(?# comment) Add inline comment
# Add x-mode comment
For detailed information and examples, see
http://aka.ms/regex
To test your regular expressions, see
http://regexlib.com/RETester.aspx
Category Description
Lu Letter, uppercase
LI Letter, lowercase
Lt Letter, title case
Lm Letter, modifier
Lo Letter, other
L Letter, all
Mn Mark, nonspacing combining
Mc Mark, spacing combining
Me Mark, enclosing combining
M Mark, all diacritic
Nd Number, decimal digit
Nl Number, letterlike
No Number, other
N Number, all
Pc Punctuation, connector
Pd Punctuation, dash
Ps Punctuation, opening mark
Pe Punctuation, closing mark
Pi Punctuation, initial quote mark
Pf Puntuation, final quote mark
Po Punctuation, other
P Punctuation, all
Sm Symbol, math
Sc Symbol, currency
Sk Symbol, modifier
So Symbol, other
S Symbol, all
Zs Separator, space
Zl Separator, line
Zp Separator, paragraph
Z Separator, all
Cc Control code
Cf Format control character
Cs Surrogate code point
Co Private-use character
Cn Unassigned
C Control characters, all
For named character set blocks (e.g., Cyrillic), search
for "supported named blocks" in the MSDN Library.
Class: System.Text.RegularExpressions.Regex
Pattern matching with Regex objects
To initialize with Use constructor
Regular exp Regex(String)
+ options Regex(String, RegexOptions)
+ time-out Regex(String, RegexOptions,
TimeSpan)
Pattern matching with static methods
Use an overload of a method below to supply the
regular expression and the text you want to search.
Finding and replacing matched patterns
To Use method
Validate match Regex.IsMatch
Retrieve single
match
Regex.Match (first)
Match.NextMatch (next)
Retrieve all
matches
Regex.Matches
Replace match Regex.Replace
Divide text Regex.Split
Handle char
escapes
Regex.Escape
Regex.Unescape
Getting info about regular expression patterns
To get Use Regex API
Group names GetGroupNames
GetGroupNameFromNumber
Group numbers GetGroupNumbers
GetGroupNumberFromName
Expression ToString
Options Options
Time-out MatchTimeOut
Cache size CacheSize
Direction RightToLeft
Regular expressions quick reference

More Related Content

What's hot

Regex Presentation
Regex PresentationRegex Presentation
Regex Presentation
arnolambert
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Raj Gupta
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
Masudul Haque
 
16 Java Regex
16 Java Regex16 Java Regex
16 Java Regex
wayn
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
Bharat17485
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
Tri Truong
 
The Power of Regular Expression: use in notepad++
The Power of Regular Expression: use in notepad++The Power of Regular Expression: use in notepad++
The Power of Regular Expression: use in notepad++
Anjesh Tuladhar
 

What's hot (20)

Regex Presentation
Regex PresentationRegex Presentation
Regex Presentation
 
Andrei's Regex Clinic
Andrei's Regex ClinicAndrei's Regex Clinic
Andrei's Regex Clinic
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular expression
Regular expressionRegular expression
Regular expression
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regex cheatsheet
Regex cheatsheetRegex cheatsheet
Regex cheatsheet
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
16 Java Regex
16 Java Regex16 Java Regex
16 Java Regex
 
Textpad and Regular Expressions
Textpad and Regular ExpressionsTextpad and Regular Expressions
Textpad and Regular Expressions
 
Finaal application on regular expression
Finaal application on regular expressionFinaal application on regular expression
Finaal application on regular expression
 
Introduction to regular expressions
Introduction to regular expressionsIntroduction to regular expressions
Introduction to regular expressions
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
Python (regular expression)
Python (regular expression)Python (regular expression)
Python (regular expression)
 
Python - Regular Expressions
Python - Regular ExpressionsPython - Regular Expressions
Python - Regular Expressions
 
Regular Expressions grep and egrep
Regular Expressions grep and egrepRegular Expressions grep and egrep
Regular Expressions grep and egrep
 
The Power of Regular Expression: use in notepad++
The Power of Regular Expression: use in notepad++The Power of Regular Expression: use in notepad++
The Power of Regular Expression: use in notepad++
 

Viewers also liked

2013캄보디아
2013캄보디아2013캄보디아
2013캄보디아
christmh
 
Chươngii
ChươngiiChươngii
Chươngii
jvinhit
 
Live stream from myoStream
Live stream from myoStreamLive stream from myoStream
Live stream from myoStream
myostream
 

Viewers also liked (8)

Diabetes Health Reminders
Diabetes Health RemindersDiabetes Health Reminders
Diabetes Health Reminders
 
Diabetes Health Reminders
Diabetes Health RemindersDiabetes Health Reminders
Diabetes Health Reminders
 
2013캄보디아
2013캄보디아2013캄보디아
2013캄보디아
 
Vemma
VemmaVemma
Vemma
 
Chươngii
ChươngiiChươngii
Chươngii
 
Live stream from myoStream
Live stream from myoStreamLive stream from myoStream
Live stream from myoStream
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Similar to Regular expressions quick reference

Similar to Regular expressions quick reference (20)

mhg
mhgmhg
mhg
 
An Introduction to Regular expressions
An Introduction to Regular expressionsAn Introduction to Regular expressions
An Introduction to Regular expressions
 
Regular expressions in oracle
Regular expressions in oracleRegular expressions in oracle
Regular expressions in oracle
 
Regexps
RegexpsRegexps
Regexps
 
Expresiones Regulares
Expresiones RegularesExpresiones Regulares
Expresiones Regulares
 
Adv. python regular expression by Rj
Adv. python regular expression by RjAdv. python regular expression by Rj
Adv. python regular expression by Rj
 
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
 
test
testtest
test
 
Video added by Normal user
Video added by Normal user Video added by Normal user
Video added by Normal user
 
Resource one
Resource one Resource one
Resource one
 

More from jvinhit (7)

Web performance fundamental
Web performance fundamentalWeb performance fundamental
Web performance fundamental
 
CSS Căn bản
CSS Căn bảnCSS Căn bản
CSS Căn bản
 
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper ClassesUsing The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
 
Network Programming in C#
Network Programming in C#Network Programming in C#
Network Programming in C#
 
Xử lý ảnh
Xử lý ảnhXử lý ảnh
Xử lý ảnh
 
Delegate và event trong C#
Delegate và event trong C#Delegate và event trong C#
Delegate và event trong C#
 
Store procedure
Store procedureStore procedure
Store procedure
 

Recently uploaded

一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
StarCompliance.io
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
Exploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptxExploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptx
DilipVasan
 
Computer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage sComputer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage s
MAQIB18
 

Recently uploaded (20)

Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
Tabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflowsTabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflows
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
 
Pre-ProductionImproveddsfjgndflghtgg.pptx
Pre-ProductionImproveddsfjgndflghtgg.pptxPre-ProductionImproveddsfjgndflghtgg.pptx
Pre-ProductionImproveddsfjgndflghtgg.pptx
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPsWebinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
 
Exploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptxExploratory Data Analysis - Dilip S.pptx
Exploratory Data Analysis - Dilip S.pptx
 
Computer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage sComputer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage s
 
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
 
Using PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDBUsing PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDB
 

Regular expressions quick reference

  • 1. Use To match any character [set] In that set [^set] Not in that set [a–z] In the a-z range [^a–z] Not in the a-z range . Any except n (new line) char Escaped special character Use To match Unicode t Horizontal tab u0009 v Vertical tab u000B b Backspace u0008 e Escape u001B r Carriage return u000D f Form feed u000C n New line u000A a Bell (alarm) u0007 c char ASCII control character  Use To match character with octal 2-3 digit octal character code x hex 2-digit hex character code u hex 4-digit hex character code Use To match character p{ctgry} In that Unicode category or block P{ctgry} Not in that Unicode category or block w Word character W Non-word character d Decimal digit D Not a decimal digit s White-space character S Non-white-space char Greedy Lazy Matches * *? 0 or more times + +? 1 or more times ? ?? 0 or 1 time {n} {n}? Exactly n times {n,} {n,}? At least n times {n,m} {n,m}? From n to m times Use To specify position ^ At start of string or line A At start of string z At end of string Z At end (or before n at end) of string $ At end (or before n at end) of string or line G Where previous match ended b On word boundary B Not on word boundary Use To define (exp) Indexed group (?<name>exp) Named group (?<name1- name2>exp) Balancing group (?:exp) Noncapturing group (?=exp) Zero-width positive lookahead (?!exp) Zero-width negative lookahead (?<=exp) Zero-width positive lookbehind (?<!exp) Zero-width negative lookbehind (?>exp) Non-backtracking (greedy) Option Effect on match i Case-insensitive m Multiline mode n Explicit (named) s Single-line mode x Ignore white space Use To (?imnsx- imnsx) Set or disable the specified options (?imnsx- imnsx:exp) Set or disable the specified options within the expression June 2014  2014 Microsoft. All rights reserved.
  • 2. Use To match n Indexed group k<name> Named group Use To match a |b Either a or b (?(exp) yes | no) yes if exp is matched no if exp isn't matched (?(name) yes | no) yes if name is matched no if name isn't matched Use To substitute $n Substring matched by group number n ${name} Substring matched by group name $$ Literal $ character $& Copy of whole match $` Text before the match $' Text after the match $+ Last captured group $_ Entire input string Use To (?# comment) Add inline comment # Add x-mode comment For detailed information and examples, see http://aka.ms/regex To test your regular expressions, see http://regexlib.com/RETester.aspx Category Description Lu Letter, uppercase LI Letter, lowercase Lt Letter, title case Lm Letter, modifier Lo Letter, other L Letter, all Mn Mark, nonspacing combining Mc Mark, spacing combining Me Mark, enclosing combining M Mark, all diacritic Nd Number, decimal digit Nl Number, letterlike No Number, other N Number, all Pc Punctuation, connector Pd Punctuation, dash Ps Punctuation, opening mark Pe Punctuation, closing mark Pi Punctuation, initial quote mark Pf Puntuation, final quote mark Po Punctuation, other P Punctuation, all Sm Symbol, math Sc Symbol, currency Sk Symbol, modifier So Symbol, other S Symbol, all Zs Separator, space Zl Separator, line Zp Separator, paragraph Z Separator, all Cc Control code Cf Format control character Cs Surrogate code point Co Private-use character Cn Unassigned C Control characters, all For named character set blocks (e.g., Cyrillic), search for "supported named blocks" in the MSDN Library. Class: System.Text.RegularExpressions.Regex Pattern matching with Regex objects To initialize with Use constructor Regular exp Regex(String) + options Regex(String, RegexOptions) + time-out Regex(String, RegexOptions, TimeSpan) Pattern matching with static methods Use an overload of a method below to supply the regular expression and the text you want to search. Finding and replacing matched patterns To Use method Validate match Regex.IsMatch Retrieve single match Regex.Match (first) Match.NextMatch (next) Retrieve all matches Regex.Matches Replace match Regex.Replace Divide text Regex.Split Handle char escapes Regex.Escape Regex.Unescape Getting info about regular expression patterns To get Use Regex API Group names GetGroupNames GetGroupNameFromNumber Group numbers GetGroupNumbers GetGroupNumberFromName Expression ToString Options Options Time-out MatchTimeOut Cache size CacheSize Direction RightToLeft