How to check if there is any character between two words?


I have a string with two words “Hello friends” that can be separated by a number of blank spaces undefined.

Sometimes there is a extra word between both words “Hello hey friends” → in this case “hey” but any other word can be between these words

How could I check if there is a extra word?


Hope the following expression helps you.

not System.Text.RegularExpressions.Regex.IsMatch(text,"Hello\s+?friends")

This will return true if there is other word.



This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.