My input is
This is <a> <test> mat<ch>.
Output should be
1. <a>
2. <test>
3. <ch>
I have tried this
string input1 = "This is <a> <test> mat<ch>.";
var m1 = Regex.Matches(input1, @"<(.*)>");
var list = new List<string>();
foreach (Match match in m1)
{
list.Add(match.Value);
}
This returns <a> <test> mat<ch>
as single element in list.
Make your regex non greedy
var m1 = Regex.Matches(input1, @"<(.*?)>");
Or use negation based regex
var m1 = Regex.Matches(input1, @"<([^>]*)>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With