Javascript Regex Cheat Sheet



Some people say- “Not learning JavaScript means you are not a serious developer”. But learning the whole JavaScript is really tough. So, an easy way to have frequent things handy, we have JavaScript Cheat Sheet!!

JavaScript is a very popular client-side scripting language. It is adopted universally for supporting dynamic content in a webpage. JavaScript makes a site more interactive & brings special effects to it. It is also applicable to external applications like PDF, widgets etc. If you are a web developer, you also need JavaScript. We have devised a list of top JavaScript cheat sheets. You can keep this list by your side when working on any JavaScript project as a great resource. Here at TemplateToaster web design software, I have listed the best JavaScript cheat sheets.

JavaScript Cheat Sheet

JavaScript cheat sheets will work as memory refreshing tools while developing a website. A JavaScript cheat sheet provides simple, brief instructions for executing JavaScript on a web page. It will help you to get started with JavaScript and let you know what all the things you can do with it. Here at Templatetoaster website builder, Let’s explore some of the best JavaScript cheat sheets listed below

1. Cheatography Cheat Sheet

Regular Expressions Cheat Sheet by DaveChild - Cheatography.com Created Date: 4237Z. Test your Javascript and PCRE regular expressions online.

This JavaScript Cheat sheet is formulated by Dave Child. It enlists all the JavaScript methods and functions under different categories. All the categories are well-chosen and maintained to display the JavaScript syntax. The major categories are Regular Expression syntax, Pattern Modifiers, JavaScript Arrays, Event Handlers, Strings etc. It incorporates all the methods for string, date, number and math operations, to manage the events and much more. It also includes JavaScript Regular Exp Objects and functions.

2. OverAPI Cheat Sheet

It is a comprehensive JavaScript Cheat sheet from the OverAPI collection of cheat sheets. Not only it groups the hole JavaScript syntax at one place but also redirects you to new links for the further details. It means whenever you click a specific element, it opens a new page that contains its syntax, short summary, and description with an example. Covers all the basic functions plus Graphics Methods and DOM properties. It is a great JavaScript resource as holds everything you need to know about it.

3. FirstSiteGuide Cheat Sheet

You can get a fancy JavaScript Cheat Sheet on FirstSiteGuide. It is a good exposure to JavaScript syntax for beginners. Gives you a brief overview of JavaScript variables, commands, functions, and methods under different categories. This colorful JavaScript collaboration is easy to refer and follow.

4. DOM JavaScript Cheat Sheet (PDF)

This cheat sheet is assembled by Christian Heilmann. It is a collection of the most commonly used DOM methods in JavaScript. It is really useful to locate an element, for navigating between nodes, reading element attributes and node values etc. Even, you can create new nodes.

5. JavaScript Regex Cheatsheet

In JavaScript, regular expressions are objects to match character combinations in strings. These are used with different methods of a string. So, this JavaScript Regex cheat sheet covers all the regex basics, quantifiers, classes to Regex replacement. It also includes Regex groups, assertions, and Regex flags. In whole, it is good quick reference to all the concepts associated with JavaScript Regular expressions.

6. JavaScript (ES6 and Beyond) Cheat Sheet

This JavaScript Cheat Sheet refers to the latest standard specification ES6 of JavaScript. ECMAScript (ES6) is a new JavaScript implementation. It focuses that how to create a scripting language. This cheat sheet displays the ES6 features of JavaScript. It represents ES6 variable, constants, Binary, Hex, and Octal notation, Arrow, and new scoped functions and much more. It is one of the best resources to get aware of new ES6 elements and concepts.

7. React.js Cheat Sheet

This cheat sheet represents a JavaScript library for creating user interfaces. It has a number of sections to target React v15 to v16. It covers the basic components, defaults, lifecycle, DOM nodes, JSX patterns, property validation etc. Each section divides into relevant sets of operation. Rollbar sponsors this cheat sheet. Rollbar is responsible for real-time error monitoring, analytics & altering for developers.

8. Interactive JavaScript Cheat Sheet

This JavaScript Cheat Sheet summarizes the all useful elements on a single page. It marks the code example for every element included. Contains different sections for loops, variables, arrays, strings, events, numbers, dates, functions etc. It also encapsulates the Regular Expressions, Errors, JSON, Promises. You can easily copy paste the code examples for your projects.

9. JavaScript in One Pic

This is a beautiful representation of JavaScript Cheat Sheet in a single picture. You can find it in GitHub repository. It’s like a tree of JavaScript syntax. Every branch of which indicates a JavaScript method or function. The left portion of the tree tells about the scope of JavaScript elements including the global, execution context, scope chain, and closure. Whereas the right branches explain about functions, identifiers, comments, data type, operators, reference type & flow control. The extreme nodes have example code. A graphical representation is always beneficial when it comes to interpret and memorize plain text. It is great to understand the flow and structure of JavaScript syntax.

10. Dummies Cheat Sheet

This JavaScript Cheat Sheet is in tabular form. Contains all the JavaScript syntax including variables, functions, and methods with description. It has classified the syntax in Variable Manipulation functions, Basic I/O commands, Structural Conditioning, Objects, DOM Methods, Regular expressions etc. Includes main jQuery selector and Filters.

11. Codepen Cheat Sheet

It is a simple reference JavaScript Cheat Sheet on Codepen. It mainly divides into three parts based on its working: Data Object Methods (DOM), JS, Functions. Each part associates with some major operations. It gives the different JavaScript commands to execute the particular tasks. For Example, to create DOM elements, to add object properties, to set default values to functions and much more. You can scroll down sequentially to see all the details or can jump to any particular section with the help of the clickable links specified on the top of the cheat sheet.

12. JavaScript Cheat Sheet

This JavaScript Cheat Sheet is maintained on XUL. It has separate sections to help the user to find which variable, operator, function or method is used for performing a specific task. Each section covers most of the relevant operations to serve the user purpose. The main sections are Types of variables, Event Handlers, Date, array, index and String methods, functions, Regular expressions etc. It only gives the name of the operation or variable. For more details about that particular element, you need to go on the links in the left corner of the window.

13. Modern JS Cheatsheet

Modern JS Cheat Sheet helps the developers to get familiar with basics of JavaScript. This guide is very well-framed with a table of contents. A user can jump to any required section from the table of contents. It covers all the basics like variables, constants, array functions, classes, generators, static methods etc. Whatever section it includes, gives complete information about it, from a short explanation, sample code to the detailed explanation. It also marks the external resources to get further details. This is one of the best JavaScript cheat sheets to have a good command over this language.

14. The Ultimate JavaScript Cheat Sheet

The ultimate JavaScript Cheat Sheet not only gives an overview of the JavaScript language but also includes a couple of browser features. It covers all the basics plus error handling in JavaScript. It gives a small description, language rules, example code for every enlisted element. The main elements are variables, conditional statements, objects, classes, constructors, async function, promises etc. It also embraces loops, math & number functions, date functions.

15. JavaScript Encyclopedia

This is a JavaScript encyclopedia organized into 27 chapters. Every chapter contains a list of specimens (concepts). All these specimens are arranged alphabetically. Each specimen can include multiple articles. These are well-maintained with further links. This encyclopedia covers all the basics of JavaScript in addition to the special characters.

16. JavaScript Cheat Sheet

This is a special JavaScript Cheat Sheet. It only includes different types of expression, properties and some of the main functions of JavaScript. Comprises of Trivial expressions, Operator expressions, Composite expressions. It also incorporates Statements, Useful functions, Useful Properties of strings, arrays and maths.

17. JavaScript Cheat Sheet by Sudolabs

This is a short but quick JavaScript cheat sheet to brush-up your JavaScript language basics. It has arranged all the elements into some major sections like Output, DOM methods, Events, Variables, Loops, String Functions, Conditional Statements etc.

18. JavaScript Cheat Sheet by Hemsen

This JavaScript Cheat Sheet is formulated by Holmer Hemsen. First, it tells about the structure of a JavaScript document. It goes further step by step by explaining the brief details from Semicolon, Whitespaces to Event Handling. It covers variables, types, arrays, strings, objects & methods, operators, math & date functions to RegExp etc. Available in PDF format.javascript cheat sheet

19. JavaScript Quick Reference Card

This reference card is a summary of JavaScript. It includes all of the Code structure, Nomenclature rules, Visibility & scope to Objects. It describes an element with its proper notation. The main sections are Variables, Looping, Array objects, Error handling, JavaScript in HTML, Conditional Execution, Window Objects etc.

20. All-In-One Cheat Sheet

This is an Ultimate JavaScript Cheat Sheet that covers everything from basic objects to graphics. It includes browser functions, DOM events, RegExp, Conditionals, Timers, Loops, Type checking, throttle functions etc. In addition to this, it also tells how to create or add new elements to DOM, Add/Remove classes or array items, add default arguments for functions and much more.

21. JavaScript: Basic, Advanced, & More Cheat Sheet by AC Winter

This cheat sheet covers all the core elements of JavaScript though not in detail but to mark a reference. The main sections are of Types, Math Methods, Array, Functions, Loops, Strings, Date Methods etc. It also includes the Miscellaneous Instructions to perform some specific operations like breaking/stopping the current loop etc. Similarly, it has a separate section to define some relative language terms such as Callback, Chaining, ECMAScript, Arity, Currying, IIFE and much more. It also enlists some of the Reserved Keywords for JavaScript.

22. JavaScript Object Methods Cheat Sheet by anas_95

This JavaScript Cheat Sheet only contains the object methods. There are five main object methods for Strings, Maths, Arrays, Numbers, and Data. Each section includes the relevant methods with name and a short description. It is an easy reference guide, also available in PDF format to download.

23. JavaScript for Java Developers

This is a great JavaScript resource for the Java developers. It deals with the frequent pain points by comparing different elements of both the languages. Tells about the importance of learning JavaScript in the Java world. Explains some of the core concepts. Like having only objects and no classes, this keyword, Functions as values, Classic vs Prototypal inheritance etc. It also includes the Constructors, Closures, Modules, Block Scope and much more.

To Bind Up

C# regex cheat sheet

JavaScript has a high potential for building cutting-edge web applications. But, it’s really tough to memorize it by heart. So, the JavaScript cheat sheets act perfectly as a reminder and comprehensive reference for the developers. All the popular and special purpose cheat sheets are discussed above. Now, you have your own great database of JavaScript cheat sheets. So, enjoy working with your JavaScript coding!!

The tables below are a reference to basic regex. While reading the rest of the site, when in doubt, you can always come back and look here. (It you want a bookmark, here's a direct link to the regex reference tables). I encourage you to print the tables so you have a cheat sheet on your desk for quick reference.
The tables are not exhaustive, for two reasons. First, every regex flavor is different, and I didn't want to crowd the page with overly exotic syntax. For a full reference to the particular regex flavors you'll be using, it's always best to go straight to the source. In fact, for some regex engines (such as Perl, PCRE, Java and .NET) you may want to check once a year, as their creators often introduce new features.
The other reason the tables are not exhaustive is that I wanted them to serve as a quick introduction to regex. If you are a complete beginner, you should get a firm grasp of basic regex syntax just by reading the examples in the tables. I tried to introduce features in a logical order and to keep out oddities that I've never seen in actual use, such as the 'bell character'. With these tables as a jumping board, you will be able to advance to mastery by exploring the other pages on the site.

How to use the tables

The tables are meant to serve as an accelerated regex course, and they are meant to be read slowly, one line at a time. On each line, in the leftmost column, you will find a new element of regex syntax. The next column, 'Legend', explains what the element means (or encodes) in the regex syntax. The next two columns work hand in hand: the 'Example' column gives a valid regular expression that uses the element, and the 'Sample Match' column presents a text string that could be matched by the regular expression.
You can read the tables online, of course, but if you suffer from even the mildest case of online-ADD (attention deficit disorder), like most of us… Well then, I highly recommend you print them out. You'll be able to study them slowly, and to use them as a cheat sheet later, when you are reading the rest of the site or experimenting with your own regular expressions.
Enjoy!
If you overdose, make sure not to miss the next page, which comes back down to Earth and talks about some really cool stuff: The 1001 ways to use Regex.

Regex Accelerated Course and Cheat Sheet

For easy navigation, here are some jumping points to various sections of the page:
✽ Characters
✽ Quantifiers
✽ More Characters
✽ Logic
✽ More White-Space
✽ More Quantifiers
✽ Character Classes
✽ Anchors and Boundaries
✽ POSIX Classes
✽ Inline Modifiers
✽ Lookarounds
✽ Character Class Operations
✽ Other Syntax
(direct link)

Characters

CharacterLegendExampleSample Match
dMost engines: one digit
from 0 to 9
file_ddfile_25
d.NET, Python 3: one Unicode digit in any scriptfile_ddfile_9੩
wMost engines: 'word character': ASCII letter, digit or underscorew-wwwA-b_1
w.Python 3: 'word character': Unicode letter, ideogram, digit, or underscorew-www字-ま_۳
w.NET: 'word character': Unicode letter, ideogram, digit, or connectorw-www字-ま‿۳
sMost engines: 'whitespace character': space, tab, newline, carriage return, vertical tabasbsca b
c
s.NET, Python 3, JavaScript: 'whitespace character': any Unicode separatorasbsca b
c
DOne character that is not a digit as defined by your engine's dDDDABC
WOne character that is not a word character as defined by your engine's wWWWWW*-+=)
SOne character that is not a whitespace character as defined by your engine's sSSSSYoyo

(direct link)

Quantifiers

QuantifierLegendExampleSample Match
+One or moreVersion w-w+Version A-b1_1
{3}Exactly three timesD{3}ABC
{2,4}Two to four timesd{2,4}156
{3,}Three or more timesw{3,}regex_tutorial
*Zero or more timesA*B*C*AAACC
?Once or noneplurals?plural

(direct link)

More Characters

CharacterLegendExampleSample Match
.Any character except line breaka.cabc
.Any character except line break.*whatever, man.
.A period (special character: needs to be escaped by a )a.ca.c
Escapes a special character.*+? $^/.*+? $^/
Escapes a special character[{()}][{()}]

(direct link)

Logic

LogicLegendExampleSample Match
| Alternation / OR operand22|3333
( … )Capturing groupA(nt|pple)Apple (captures 'pple')
1Contents of Group 1r(w)g1xregex
2Contents of Group 2(dd)+(dd)=2+112+65=65+12
(?: … )Non-capturing groupA(?:nt|pple)Apple

(direct link)

More White-Space

CharacterLegendExampleSample Match
tTabTtw{2}T ab
rCarriage return charactersee below
nLine feed charactersee below
rnLine separator on WindowsABrnCDAB
CD
NPerl, PCRE (C, PHP, R…): one character that is not a line breakN+ABC
hPerl, PCRE (C, PHP, R…), Java: one horizontal whitespace character: tab or Unicode space separator
HOne character that is not a horizontal whitespace
v.NET, JavaScript, Python, Ruby: vertical tab
vPerl, PCRE (C, PHP, R…), Java: one vertical whitespace character: line feed, carriage return, vertical tab, form feed, paragraph or line separator
VPerl, PCRE (C, PHP, R…), Java: any character that is not a vertical whitespace
RPerl, PCRE (C, PHP, R…), Java: one line break (carriage return + line feed pair, and all the characters matched by v)

(direct link)

More Quantifiers

QuantifierLegendExampleSample Match
+The + (one or more) is 'greedy'd+12345
?Makes quantifiers 'lazy'd+?1 in 12345
*The * (zero or more) is 'greedy'A*AAA
?Makes quantifiers 'lazy'A*?empty in AAA
{2,4}Two to four times, 'greedy'w{2,4}abcd
?Makes quantifiers 'lazy'w{2,4}?ab in abcd

(direct link)

Character Classes

CharacterLegendExampleSample Match
[ … ]One of the characters in the brackets[AEIOU]One uppercase vowel
[ … ]One of the characters in the bracketsT[ao]pTap or Top
-Range indicator[a-z]One lowercase letter
[x-y]One of the characters in the range from x to y[A-Z]+GREAT
[ … ]One of the characters in the brackets[AB1-5w-z]One of either: A,B,1,2,3,4,5,w,x,y,z
[x-y]One of the characters in the range from x to y[ -~]+Characters in the printable section of the ASCII table.
[^x]One character that is not x[^a-z]{3}A1!
[^x-y]One of the characters not in the range from x to y[^ -~]+Characters that are not in the printable section of the ASCII table.
[dD]One character that is a digit or a non-digit[dD]+Any characters, inc-
luding new lines, which the regular dot doesn't match
[x41]Matches the character at hexadecimal position 41 in the ASCII table, i.e. A[x41-x45]{3}ABE

(direct link)

Anchors and Boundaries

AnchorLegendExampleSample Match
^Start of string or start of line depending on multiline mode. (But when [^inside brackets], it means 'not')^abc .*abc (line start)
$End of string or end of line depending on multiline mode. Many engine-dependent subtleties..*? the end$this is the end
ABeginning of string
(all major engines except JS)
Aabc[dD]*abc (string...
...start)
zVery end of the string
Not available in Python and JS
the endzthis is...n...the end
ZEnd of string or (except Python) before final line break
Not available in JS
the endZthis is...n...the endn
GBeginning of String or End of Previous Match
.NET, Java, PCRE (C, PHP, R…), Perl, Ruby
bWord boundary
Most engines: position where one side only is an ASCII letter, digit or underscore
Bob.*bcatbBob ate the cat
bWord boundary
.NET, Java, Python 3, Ruby: position where one side only is a Unicode letter, digit or underscore
Bob.*bкошкаbBob ate the кошка
BNot a word boundaryc.*BcatB.*copycats

(direct link)

POSIX Classes

CharacterLegendExampleSample Match
[:alpha:]PCRE (C, PHP, R…): ASCII letters A-Z and a-z[8[:alpha:]]+WellDone88
[:alpha:]Ruby 2: Unicode letter or ideogram[[:alpha:]d]+кошка99
[:alnum:]PCRE (C, PHP, R…): ASCII digits and letters A-Z and a-z[[:alnum:]]{10}ABCDE12345
[:alnum:]Ruby 2: Unicode digit, letter or ideogram[[:alnum:]]{10}кошка90210
[:punct:]PCRE (C, PHP, R…): ASCII punctuation mark[[:punct:]]+?!.,:;
[:punct:]Ruby: Unicode punctuation mark[[:punct:]]+‽,:〽⁆

(direct link)

Inline Modifiers

None of these are supported in JavaScript. In Ruby, beware of (?s) and (?m).
ModifierLegendExampleSample Match
(?i)Case-insensitive mode
(except JavaScript)
(?i)MondaymonDAY
(?s)DOTALL mode (except JS and Ruby). The dot (.) matches new line characters (rn). Also known as 'single-line mode' because the dot treats the entire input as a single line(?s)From A.*to ZFrom A
to Z
(?m)Multiline mode
(except Ruby and JS) ^ and $ match at the beginning and end of every line
(?m)1rn^2$rn^3$1
2
3
(?m)In Ruby: the same as (?s) in other engines, i.e. DOTALL mode, i.e. dot matches line breaks(?m)From A.*to ZFrom A
to Z
(?x)Free-Spacing Mode mode
(except JavaScript). Also known as comment mode or whitespace mode
(?x) # this is a
# comment
abc # write on multiple
# lines
[ ]d # spaces must be
# in brackets
abc d
(?n).NET, PCRE 10.30+: named capture onlyTurns all (parentheses) into non-capture groups. To capture, use named groups.
(?d)Java: Unix linebreaks onlyThe dot and the ^ and $ anchors are only affected by n
(?^)PCRE 10.32+: unset modifiersUnsets ismnx modifiers

(direct link)

Lookarounds

LookaroundLegendExampleSample Match
(?=…)Positive lookahead(?=d{10})d{5}01234 in 0123456789
(?<=…)Positive lookbehind(?<=d)catcat in 1cat
(?!…)Negative lookahead(?!theatre)thew+theme
(?<!…)Negative lookbehindw{3}(?<!mon)sterMunster

(direct link)

Character Class Operations

Class OperationLegendExampleSample Match
[…-[…]].NET: character class subtraction. One character that is in those on the left, but not in the subtracted class.[a-z-[aeiou]]Any lowercase consonant
[…-[…]].NET: character class subtraction.[p{IsArabic}-[D]]An Arabic character that is not a non-digit, i.e., an Arabic digit
[…&&[…]]Java, Ruby 2+: character class intersection. One character that is both in those on the left and in the && class.[S&&[D]]An non-whitespace character that is a non-digit.
[…&&[…]]Java, Ruby 2+: character class intersection.[S&&[D]&&[^a-zA-Z]]An non-whitespace character that a non-digit and not a letter.
[…&&[^…]]Java, Ruby 2+: character class subtraction is obtained by intersecting a class with a negated class[a-z&&[^aeiou]]An English lowercase letter that is not a vowel.
[…&&[^…]]Java, Ruby 2+: character class subtraction[p{InArabic}&&[^p{L}p{N}]]An Arabic character that is not a letter or a number

(direct link)

Other Syntax

SyntaxLegendExampleSample Match
KKeep Out
Perl, PCRE (C, PHP, R…), Python's alternate regex engine, Ruby 2+: drop everything that was matched so far from the overall match to be returned
prefixKd+12
Q…EPerl, PCRE (C, PHP, R…), Java: treat anything between the delimiters as a literal string. Useful to escape metacharacters.Q(C++ ?)E(C++ ?)

Don't Miss The Regex Style Guide
and The Best Regex Trick Ever!!!

The 1001 ways to use Regex

1-10 of 17 Threads
Subject: Very thoughtful and useful cheat sheet

Unlike lots of other cheat sheets or regex web sites, I was able (without much persistent regex knowledge) to apply the rules and to solve my problem. THANK YOU :)
Subject: Thanks a lot

Thanks a lot for the quick guide. It's really helpful.
Subject: Very useful site

Thank you soooooo much for this site. I'm using python regex for natural language processing in sentiment analysis and this helped me a lot.
Subject: Thank you! Excellent resource for any student

Thank you so much for this incredible cheatsheet! It is facilitating a lot my regex learning! God bless you and your passion!
Subject: Thank you for doing such a geat work.

I am now learning regex and for finding such a well organized site is a blessing! You are a good soul! Thank you for everything and stay inspired!
Subject: Simple = perfect

Subject: Congratulations

Well done, very useful page. Thank you for your effort. T
Subject: Thank you very much

Hi Rex,
Thankyou very much for compiling these. I am new to text analytics and is struggling a lot with regex. This is helping me a lot pick up. Great work
Subject: Nice summary

Nice summary of regex. I was trying to remember how to group and I found the example above. Thanks.
Subject: Best Regex site ever

Javascript Regexp Cheat Sheet

This is the best regex site ever on the internet. Regular Expressions are like any other language, they require time and effort to learn. RexEgg makes it an easy journey. Great work Author. Kudos to you.


Reg Expression Cheat Sheet