I have a string which may or may not contain a code for an emote, all of which begin the same: "auroraa1"
Such as:
"auroraa1Smile", "auroraa1Bye", "auroraa1Love"
I need to be able to grab the whole code for a given emote without any of the spaces before/after and alter it.
In a sentence such as:
"Hello Aurora! auroraa1Smile How are you?"
I need to alter it to:
"Hello Aurora! [emote:4771491:auroraangel79Smile] How are you?"
Question:
How can I create a regex to capture the emote code from the source string: auroraa1Hi
My current code:
//read the twitchMsg and look for "auroraa1" which denotes an emote string wordToFind = "auroraa1";
string kickMsg = "NONE";
kickMsg = CPH.GetGlobalVar<string>("s_msg");
// Find all occurrences of the wordToFind as a whole word MatchCollection matches = Regex.Matches(kickMsg, $@"{wordToFind}", RegexOptions.IgnoreCase);
if (matches.Count > 0)
{
CPH.SendMessage($"'{wordToFind}' found {matches.Count} times as a whole word.");
foreach (Match match in matches)
{
CPH.SendMessage($"Found at index: {match.Index}");
}
}
else
{
CPH.SendMessage($"'{wordToFind}' not found as a whole word.");
}
return true;
Here's the ouput I am getting:
'auroraa1' found 1 times as a whole word.
Found at index: 28
I need output to say that it found 'auroraa1Smile'
CPH.SendMessageand other unrelated stuff? If you want to solve a problem with Regex, address just that. Please, 1) focus on exactly on issue, 2) read this: How to create a Minimal, Reproducible Example.