Hello all, I am new to regex and need some help with my current code. Below's the code I am using and results I am seeing. What I want is for it to match just the line where it sees "ID:". Would be great if I can get pointers on how to accomplish that. Thanks!
Regex idRegex = new Regex(@"ID: \s*(.*)");
if (idRegex.IsMatch(searchRange))
{
Match idMatch = idRegex.Match(searchRange);
id = idMatch.Groups[1].Value;
id = id.Trim();
}
// Below's how my searchRange looks like :-
Some random text
ID: test@test.com
---------------------Random Text -------------------------------
Results - ID:
---------------------Random Text -------------------------------
Expected - Don't need anything below the ID line. How do I match just one line. Tried RegexOptions.Singleline but got the same results.