Good day~ I am not really good at this regular expression. So I need your help, please.
Condition: Users can input their email addressed and name together. I want to extract email address and user name out of string.
string pattern1 = "Peter Jackson<[email protected]>";
From that string I want to get "Peter Jackson" and "<[email protected]>".
string pattern2 = "Peter Jackson([email protected])";
However, people always make mistakes like below.
And they can also use "[" instead of "<". so...
string pattern3 = "Peter Jackson[[email protected]]";
Even some stupid users can input like...
string pattern4 = "Peter Jackson{[email protected]}";
So, I had to look for the characters which are "<", "(", "[" and "{". I tried
string regularExpressionPattern = @"^(<|(|[|{)(.*?)^(}|]|)|>)";
But I think I've done something wrong. And I also try to think that people could input more mistake like....
string pattern5 = "Peter Jackson<[email protected]>mistake";
Could anyone help this problem? Advanced thanks.
PS: I know how to split string with a character. So it won't help. I needa proper regular expression.