Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2023-07-19 18:11
Flavor·PCRE2 (PHP)

/
(\/\/.*|\/\*[\s\S]*?\*\/)|((['"])(?:\\\3|\\?.)*?\3|`(?:\\`|\$({(?:(?1)|(?2)|(?4)|[\s\S])*?})|\\?[\s\S])*?`|\/(?:\\\/|\\?.)*?\/[gmixsuUAJD]*)
/
gm
Open regex in editor

Description

Matches comments, strings, templates, and regexes from javascript code. also matches templates recursively in order to correctly get template data

Submitted by ephf