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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -