How can I search for an exact match in a string? For example, If I had a string with this text:
label label: labels
And I search for label, I only want
You could try a LINQ version:
string str = "Hello1 Hello Hello2"; string another = "Hello"; string retVal = str.Split(" \n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries) .First( p => p .Equals(another));