Regular Expression JavaScript Notes
Based on RegEx with two groups.
RegExp.exec()
Capturing Groups w/out Global
0. RegEx Match
1. First Group
2. Second Group
Capturing Groups w/ Global
0. RegEx Match
1. First Group
2. Second Group
Non-Capturing Groups w/out Global
0. RegEx Match
Non-Capturing Groups w/ Global
0. RegEx Match
String.match()
Capturing Groups w/out Global
0. RegEx Match
1. First Group
2. Second Group
Capturing Groups w/ Global
0. First RegEx Match
1. Second RegEx Match
2. Third RegEx Match
Non-Capturing Groups w/out Global
0. RegEx Match
Non-Capturing Groups w/ Global
0. First RegEx Match
1. Second RegEx Match
2. Third RegEx Match
Minify JavaScript RegEx
Remove Single-Line Comments
\b( |\t)*//.+
[]
Remove Block Comments
/\*(.|\n)+\*/
[]
Remove space from around operators
[ ](={1,3}|\!={1,2}|\-=|\+=|\+|-|\*|\/|%|<|>|\|{1,2}|&&|\?|:)[ ]
$1
Remove spaces from the left side of parenthesis and curly braces
\s+(\(|\)|{|})
$1
Remove spaces from the right side of parenthesis, commas and colons
(\(|\)|,|:)( |\t)+
$1
Remove new lines following curly braces, parenthesis, semicolons, commas and “try” statements
(\(|\)|\{|\}|;|,|try)\s*\n+\s*
$1
Key
[] represents an empty string or null value