What should be the Regex expression to extract string between <> from the following string :
 "MyName"<[email protected]>
How do i only extract [email protected] in c# using regex ? I can extract MyName which is in-between "" using the expression : """([^""]*)""" but i find regex very confusing so can't seem to figure out how to extract the string in-between <> :(
Here it is:
public static void Main(string[] args)
{
    string input = "<[email protected]>";
    Regex rx = new Regex(@"<(.*?)>");
    Console.WriteLine(rx.Match(input).Groups[1].Value);
}
This regex contains several parts: 
< and > symbols say that my text is between them () - is group declaration, what we see here Groups[1]. Zero group would contain whole line with <> symbols .* - any character with any length ? - non-greedy search, so if you have there "<[email protected]><asdasd>" it will still return correct value and not get result [email protected]><asdasd
Example
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