-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathNamespace.regex.txt
More file actions
14 lines (14 loc) · 863 Bytes
/
Namespace.regex.txt
File metadata and controls
14 lines (14 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Finds a Namespace (captures the Name and the Content between {})
namespace # the keyword namespace FOLLOWED BY
\s{1,} # at least one whitespace character FOLLOWED BY
(?<Name>\S{1,}) # the NAME of the namespace is N-non-whitespace FOLLOWED BY
\s{0,} # optional whitespace FOLLOWED BY
(?<Content>\{ # the CONTENT starts with an opening bracket FOLLOWED BY
(?> # an atomic group CONTAINING
[^\{\}]+| # Anything that's not a bracket OR
\{(?<Depth>)|# if it's a bracket, increment depth OR
\}(?<-Depth>)# if it's a closing bracket, decrement depth
)* # 0 or more times
(?(Depth) # IF depth is set
(?!)) # this group isn't balanced, keep filling content
\}) # until we run into a closing bracket