I wanted to write a regex that would validate this: info-444444-test.json where 444444 could be any number 0-9 and 6 characters
My current regex is (info-)|(^[0-9]{6}$)|(-test.json) but it does not work on website such as https://regex101.com/
At the end I need to implement the regex into .NET into method It.IsRegex from Moq library.
In your pattern (info-)|(^[0-9]{6}$)|(-test.json) there are 3 alternatives where the pattern is trying to match each alternative starting from the left giving you partial matches.
You can use a pattern to match all the parts as one match.
This is
^info-[0-9]{6}-test\.json$
^ Start of stringinfo- Match literally[0-9]{6} Match 6 digits 0-9-test\.json Match -test.json (Note to escape the dot)$ End of stringSee a .NET regex demo