C# Regular Expression for Regular Expression Parsing
Posted
by Chris
on Stack Overflow
See other posts from Stack Overflow
or by Chris
Published on 2010-04-07T19:42:11Z
Indexed on
2010/04/07
19:43 UTC
Read the original article
Hit count: 504
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
© Stack Overflow or respective owner