我有如下所示的字符串。我的问题是:如何用Dart中的所有内容替换括号?
示例1:
示例2:
答案 0 :(得分:0)
使用RegExp:
void main() {
String _myText1 = "Netflix.com(Amsterdam)";
print(_myText1.replaceAll(RegExp(r'\(.*\)'), '')); // Netflix.com
String _myText2 = "The dog has a long(brown) tail.";
print(_myText2.replaceAll(RegExp(r'\(.*\)'), '')); // The dog has a long tail.
}