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 can try to split the string (in this case the right separator can be the space but it depends by the case) and after you can use the equals method to see if there's the match e.g.:
private Boolean findString(String baseString,String strinfToFind, String separator)
{
foreach (String str in baseString.Split(separator.ToCharArray()))
{
if(str.Equals(strinfToFind))
{
return true;
}
}
return false;
}
And the use can be
findString("Label label Labels:", "label", " ");