我有一些 .NET RegExp 代碼,我正在嘗試將其轉換為 Dart/Flutter。我看到微軟有一些專有的塊名稱,如“IsCJKSymbolsandPunctuation”,但這里存在類似的名稱:
我的最終目標是
// r"\p{IsCJKSymbolsandPunctuation}\p{IsEnclosedCJKLettersandMonths}\p{IsCJKCompatibility}\p{IsCJKUnifiedIdeographsExtensionA}\p{IsCJKUnifiedIdeographs}\p{IsCJKCompatibilityIdeographs}\p{IsCJKCompatibilityForms}";
是輸入代碼點的唯一方法嗎?
uj5u.com熱心網友回復:
您可以使用
var something = "你好".replaceAll(RegExp(r"\p{Script=Hani}", unicode: true), "");
\p{Script=Hani}將匹配任何中文字符,與\p{Han}PCRE相同。
飛鏢測驗:
String text = "Abc 123 - 你好!";
print(text.replaceAll(RegExp(r"\p{Script=Hani}", unicode: true), ""));
輸出:
Abc 123 - !
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/371756.html
