Closed littepointR closed 1 year ago
It seems that because the regex Detector.IdentifiersDetectionRegex only matches ascii characters
Yes, probably the regex could be extended. As usual any help is appreciated ...
Any progress?
I need this Identifiers Detector support this too, then ChatGPT give the solution like this.
- private static readonly Regex IdentifiersDetectionRegex = new Regex(@"([^\.]|^)\b(?<id>[a-zA-Z_]\w*)\b", RegexOptions.Compiled);
+ private static readonly Regex IdentifiersDetectionRegex = new Regex(@"([^\.]|^)\b(?<id>[\p{L}_]\w*)\b", RegexOptions.Compiled);
which gives a regex ([^\.]|^)\b(?<id>[\p{L}_]\w*)\b
for both acsii and non-acsii identifier,
here is test from regex101
works for me.
Relevant section of the C# specifications: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure#643-identifiers
My test code is:
and ouput: