c# - How to match complete word to complete word seperated by space -
i want perform search operation on string. e.g have following string
hi name babar , .net developer
now if want search if word present in string or not using following code.
if(str.contains("am")) { return true; }
there problem in method return 2 word matched am , name. result am correct want result should complete word separated space. should not return name result. should match complete word not part of it. kindly me in problem
i think best solution regular expressions.
look here: c#, regex.match whole words
regular expressions more efficient , more versatile. of course, cannon sparrow , better use contains() or similar.
Comments
Post a Comment