Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niklongstone/regular-expression-cheat-sheet
Regular Expression Cheat Sheet - PCRE
https://github.com/niklongstone/regular-expression-cheat-sheet
Last synced: about 2 months ago
JSON representation
Regular Expression Cheat Sheet - PCRE
- Host: GitHub
- URL: https://github.com/niklongstone/regular-expression-cheat-sheet
- Owner: niklongstone
- Created: 2015-07-05T08:21:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-19T08:01:50.000Z (about 3 years ago)
- Last Synced: 2024-07-20T01:25:39.008Z (2 months ago)
- Size: 1.95 KB
- Stars: 286
- Watchers: 7
- Forks: 85
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Regular Expression Cheat Sheet - PCRE
|Anchor|Description|Example|Valid match|Invalid|
:---|:---|:---|:---|---
^|start of string or line|^foam|foam|bath foam|
\A|start of string in any match mode|\Afoam|foam|bath foam|
$|end of string or line|finish$|finish|finnish|
\Z|end of string, or char before last new line in any match mode|finish\Z|finish|finnish|
\z|end of string, in any match mode.|
\G|end of the previous match or the start of the string for the first match|\^(get\|set)\|\G\w+$|setValue|seValue
\b|word boundary; position between a word character (\w), and a nonword character (\W)|\bis\b|This island is beautiful|This island isn't beautiful
\B|not-word-boundary.|\Bland|island|peninsula|Assertion|Description|Example|Valid match|Invalid|
:---|:---|:---|:---|---
(?=...)|positive lookahead|question(?=s)|questions|question
(?!...)|negative lookahead|answer(?!s)|answer| answers
(?<=...)|positive look-behind|(?<=appl)e|apple|application
(?...)|subpattern, and capture submatch into *name*|`(?Phello)`|hello|hallo
(?:...)|subpattern, but does not capture submatch|(?:hello)|hello|hallo
+| one or more quantifier|ye+ah|yeah, yeeeah|yah
*| zero or more quantifier|ye*ah|yeeah, yeeeah, yah|yeh
?| zero or one quantifier|yes?|yes, ye|yess
??| zero or one, as few times as possible (lazy)|yea??h|yeah|yeaah|
+?| one or more lazy |`/<.+?>/g`|`foo
` matches only `` and `
`|
*?| zero or more, lazy|`/<.*?>/g`|``|
{n}|n times exactly|fo{2}|foo|fooo
{n,m}|from n to m times|go{2,3}d|good,goood|gooood
{n,}|at least n times|go{2,}|goo, gooo|go
(?(condition)...)|if-then pattern|`(<)?[p](?(1)>)`|``, p|