0% found this document useful (0 votes)
51 views1 page

Cheatsheet Expresiones Regulares

This document is a cheat sheet for regular expressions. It provides summaries of anchors, assertions, groups and ranges, character classes, quantifiers, escape sequences, special characters, common metacharacters, string replacements, and POSIX character classes that are used in regular expressions. The cheat sheet acts as a quick reference for the syntax and special characters used in regular expressions.

Uploaded by

Andrew Gamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views1 page

Cheatsheet Expresiones Regulares

This document is a cheat sheet for regular expressions. It provides summaries of anchors, assertions, groups and ranges, character classes, quantifiers, escape sequences, special characters, common metacharacters, string replacements, and POSIX character classes that are used in regular expressions. The cheat sheet acts as a quick reference for the syntax and special characters used in regular expressions.

Uploaded by

Andrew Gamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Regular Expressions Cheat Sheet

by Dave Child (DaveChild) via cheatography.com/1/cs/5/

Anchors Assertions Groups and Ranges

^ Start of string, or start of line in multi- ?= Lookahead assertion . Any character except new line (\n)
line pattern ?! Negative lookahead (a|b) a or b
\A Start of string ?<= Lookbehind assertion (...) Group
$ End of string, or end of line in multi- ?!= or ?<! Negative lookbehind (?:...) Passive (non-capturing) group
line pattern
?> Once-only Subexpression [abc] Range (a or b or c)
\Z End of string
?() Condition [if then] [^abc] Not (a or b or c)
\b Word boundary
?()| Condition [if then else] [a-q] Lower case letter from a to q
\B Not word boundary
?# Comment [A-Q] Upper case letter from A to Q
\< Start of word
[0-7] Digit from 0 to 7
\> End of word Quantifiers
\x Group/subpattern number "x"
* 0 or more {3} Exactly 3
Character Classes Ranges are inclusive.
+ 1 or more {3,} 3 or more
\c Control character Pattern Modifiers
? 0 or 1 {3,5} 3, 4 or 5
\s White space
Add a ? to a quantifier to make it ungreedy. g Global match
\S Not white space
Escape Sequences i* Case-insensitive
\d Digit
m* Multiple lines
\D Not digit
\ Escape following character s* Treat string as single line
\w Word \Q Begin literal sequence
x* Allow comments and whitespace
\W Not word \E End literal sequence in pattern
\x Hexadecimal digit
"Escaping" is a way of treating characters e* Evaluate replacement
\O Octal digit which have a special meaning in regular U* Ungreedy pattern
expressions literally, rather than as special
POSIX * PCRE modifier
characters.

[:upper:] Upper case letters Common Metacharacters String Replacement


[:lower:] Lower case letters
$n nth non-passive group
[:alpha:] All letters ^ [ . $
$2 "xyz" in /^(abc(xyz))$/
{ * ( \
[:alnum:] Digits and letters
$1 "xyz" in /^(?:abc)(xyz)$/
+ ) | ?
[:digit:] Digits
$` Before matched string
< >
[:xdigit:] Hexadecimal digits
$' After matched string
[:punct:] Punctuation The escape character is usually \
$+ Last matched string
[:blank:] Space and tab Special Characters
$& Entire matched string
[:space:] Blank characters
\n New line Some regex implementations use \ instead
[:cntrl:] Control characters
of $.
\r Carriage return
[:graph:] Printed characters
\t Tab
[:print:] Printed characters and spaces
\v Vertical tab
[:word:] Digits, letters and underscore
\f Form feed

\xxx Octal character xxx

\xhh Hex character hh

By Dave Child (DaveChild) Published 19th October, 2011. Sponsored by Readable.com


cheatography.com/davechild/ Last updated 12th March, Measure your website readability!
aloneonahill.com 2020. Page 1 of 1. https://readable.com

You might also like