Regex matches dynamic pattern
I have a string that I need to parse using Regex (or Match):
SomeTextHereThatIWantToIgnore: <First Month.104.yyyy-mm-dd> <Last Day.2.yyyy-mm-dd>" OR SomeTextHereThatIWantToIgnore: "<BadVerb.104>"
There may be one, two or three lines (all on one line) that I want to parse. In each case, I want to capture everything between "<" and ">".
So, in the first example, I want to capture "First Month.104.yyyy-mm-dd" and "Last Day.2.yyyy-mm-dd". In the second example, I would like to capture "BadVerb.104".
Any Regex gurus who can show me how to do this?
source to share
Thanks, stribizhev, I didn't know about the Matches collection. I ended up making a simple template:
[<]([^>]+)
that is, search for "<" and then grab anything that is not ">". The collection of matches is the part I was looking for. I repeated the assembly of Match and was able to parse the resulting string and get what I wanted.
Thanks to Sami, Kartik and Walker (it looks simple too).
source to share