测试了这个 how to remove brackets character in string (java) 但它在 Dart 中不起作用。删除字符串中的 ( ) 有什么技巧吗?
我的代码:
String num = (85);
num.replaceAll("\\p{P}", "");
结果应该是:85
答案 0 :(得分:1)
您需要使用带有 RegExp
参数的编译后的 unicode: true
对象:
String num = "(85)";
print(num.replaceAll(new RegExp(r"\p{P}", unicode: true), ""));
此输出 85
as \p{P}
现在被视为标点正确匹配 Unicode 属性类正则表达式。