I have this string: "asdf"
And it is not recognized by this regex: ^[\p{L}]{3,32}$. As far as I know, the \p{L} should match any unicode letter. Why doesn't it? When i replace it with A-Za-z it works fine, but i need unicode characters. How can i fix this?
0
votes
1 Answers
0
votes
// [\p{L}]{3,32}
// A character with the Unicode property “letter” (any kind of letter from any language) «[\p{L}]{3,32}» Between 3 and 32 times, as many times as possible, giving back as needed (greedy) «{3,32}»
By definition : " is not a letter in any of the language!
Try this Regex : ^"[\p{L}]{3,32}"$
using System;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
Console.WriteLine(Regex.IsMatch("\"asdf\"", "^\"[\\p{L}]{3,32}\"$")); //True
}
}
\p{L}unless you need to add more characters to the class. - Sergey Kalinichenko@that doesn't need to double the slash. ideone.com/gtbO5t - nhahtdh"\"asdf\""- Parimal Raj[A-Za-z]worked for him, right? - Sergey Kalinichenko