-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathStruct.regex.txt
18 lines (17 loc) · 1.06 KB
/
Struct.regex.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Matches a C/C++ Struct
(?-i)struct # Starts with a literal struct
\s{1,} # Followed by whitespace
(?<Identifier>[_a-zA-Z][_a-zA-Z0-9]{1,}) # Followed by an identifier
[\s\n\r]{0,} # Followed by optional whitespace
(?<Comment>//.+[\r\n])? # Followed by an optional comment
[\s\n\r]{0,} # Followed by optional whitespace
(?<Values>(?<BalancedCurlyBracket>
\{ # An open {
(?> # Followed by...
[^\{\}]+| # any number of non-bracket character OR
\{(?<Depth>)| # 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 }
)
) # Followed by balanced curly braces