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

Hello,

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?

Hi,

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.

Regards,

3 Likes

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