0

我有这个字符串:"asdf" 并且这个正则表达式无法识别它:^[\p{L}]{3,32}$。据我所知,\p{L}应该匹配任何 unicode 字母。为什么不呢?当我用 A-Za-z 替换它时,它工作正常,但我需要 unicode 字符。我怎样才能解决这个问题?

4

1 回答 1

0
// [\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}»

根据定义:"不是任何语言的字母!

试试这个正则表达式:^"[\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
    }
}
于 2013-02-07T21:27:19.820 回答