Using .Net Core 3.1, I have built the following xUnit test to test my regex that is supposed to match certain words, or those same words followed by numbers:
[Theory]
[InlineData("Some Demo543 Company", true)]
[InlineData("Some Company", false)] //why is this one failing
[InlineData("Some Company123", false)] //why is this one failing
[InlineData("Some Test123 Company", true)]
[InlineData("Some Testing123 Company", true)]
[InlineData("Some Example123 Company", true)]
[InlineData("Some Demonstration321 Company", true)]
[InlineData("demo123", true)]
[InlineData("Testing123", true)]
[InlineData("Company123", false)]
[InlineData("Company", false)]
public void TestRegexSentenceContainsWholeWordWithNumber(string sentence, bool expectedResult)
{
string pattern = @"\b[example|demo|demonstration|test|testing]+\d*\b";
var re = new Regex(pattern, RegexOptions.IgnoreCase);
re.Match(sentence).Success.ShouldBe(expectedResult);
}
Here is a screenshot of the test run result, showing that "Some Company" and "Some Company123" are failing:
Yet, when I try the same using regex101.com, then it correctly shows that the input does NOT match the regex, as shown in the next two screen shots:

Why is this failing in my .NetCore3.1 runtime?

