C# Regular Expression for Regular Expression Parsing
- by Chris
I want to returns matches from a regular expression string. The regex string is:
(?<TICKER>[A-Z]+)(?<SPACE>\\s)(?<MONTH_ALPHA_ABBREV>Jan|Feb|Mar|Apr|May|Jun|Jul|Sep|Oct|Nov|Dec)(?<SPACE>\\s)(?<DAY>\\d+)(?<SPACE>\\s)(?<YEAR_LONG>[2][0][0-9][0-9])(?<SPACE>\\s)(?<STRIKE_DOLLAR>\\d+(?=[.]))[.](?<STRIKE_DECIMAL>(?<=[.])\\d+)(?<SPACE>\\s)(?<PUTCALL_LONG>Call|Put)
And I want to get matches for all of the group names and all of the items within square brackets (including the square brackets) outside of open and closed parenthesis. I have this regex:
((?<=[<])([A-Z]|[_])+(?=[>]))|(\\[.\\])
But this returns square bracket items within the parenthesis. To be more specific these are the matches I want from the regex at the top (keep in mind this needs to be flexible for any regex):
TICKER
SPACE
MONTH_ALPHA_ABBREV
SPACE
DAY
SPACE
YEAR_LONG
SPACE
STRIKE_DOLLAR
[.]
STRIKE_DECIMAL
SPACE
PUTCALL_LONG