diff --git a/RegEx/JavaScript/Class.regex.txt b/RegEx/JavaScript/Class.regex.txt new file mode 100644 index 0000000..62abc98 --- /dev/null +++ b/RegEx/JavaScript/Class.regex.txt @@ -0,0 +1,17 @@ +# Matches a JavaScript Class +class # Class Keyword +\s+ # Whitespace +(?\S){1,} # Class Name +\s{0,} # Optional whitespace +(?[^\{]{0,})\s{0,} # Optional whitespace +(?(? +\{ # An open { +(?> # Followed by... + [^\{\}]+| # any number of non-bracket character OR + \{(?)| # an open curly bracket (in which case increment depth) OR + \}(?<-Depth>) # a closed curly bracket (in which case decrement depth) +)*?(?(Depth)(?!)) # until depth is 0. +\} # followed by a } +) +) # The class body +