2021-01-30

How to find a word directly after another word in a string C#

I'm trying to take a string find if the string contains a word, in my case the word "Message", and then if it contains that word find the word directly after it. My relevant code so far is as follows.

public bool Find(string Word,string Text)
{
    return Text.Contains(Word);     
}

And then it uses the function in various ways but for this specific purpose It needs to find "Message" as follows

if (Find("Message", MessageText))
{
    //I don't know what to put here
}

I need to take the string MessageText and Then find Message within the string and then output the first word after the word Message. e.g "Whatever random string Message Brad and more random string" I want to output Brad



from Recent Questions - Stack Overflow https://ift.tt/3r4YAoK
https://ift.tt/eA8V8J

No comments:

Post a Comment