Skip to content →

Smallest Regular Expression Cheatsheet

Made this small table (read regular expression cheatsheet) while revising my regex concepts. Please feel free to comment, and tell me where it was wrong or add some quick references so that I could possibly expand it. 

Regex  Matches   
/the/  Other or the   
/\bthe\b/  lorem the impsum   
/[Tt]he/  The or the  [] 
/[a-z]  Any character (atleast one) between a to z   
/wha*t/  what or whaaat or even wht  * 
/wha+t/  whaor whaat but not wht  + 
H(ey|i)  Hey or Hi  | 
[^Ss]  Any character i.e neither S nor s  ^ 
/^The/  Matches The only at beginning of a line  ^ 
/never$/  Matches never. only at end of line   
/colou?r/  coloor colour  ? 
/beg.n/  Began, begin (only one character)  * 
/a\.{3}e/  a...e (matches exactly three characters)  {} 

 

Published in Algorithms

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.