Peter Rieszon Stack Overflow • Recommends
On “How does Visual Studio syntax-highlight strings in the Regex constructor?”
.NET 7 introduces the new StringSyntax(...) attribute, which is used in .NET 7 on more than 350 string , string[] , and ReadOnlySpan<char> parameters, properties, and fields to highlight to an interested tool what kind of syntax is expected to be passed or set.
— https://devblogs.microsoft.com/dotnet/regular-expression-improvements-in-dotnet-7/#stringsyntaxattribute.regex
So for a method argument, you should just use:
void MyMethod(StringSyntax(StringSyntaxAttribute.Regex) string regex);
Here is a video demonstrating the feature: link to this video