我有字符串谁是
String hello = "test test {Brian} have you {Adam} always and {Corner} always";
想让列表字符串谁是谁有{string}输出:
List<String> data = ["{Brian}","{Adam}","{Corner}"];
这在dart中是可能的吗?
我不知道该用什么
您可以通过使用RegExp(r"{[^{}]*}")
String hello = "test test {Brian} have you {Adam} always and {Corner} always";
RegExp regExp = RegExp(r"{[^{}]*}");
print(regExp.allMatches(hello).map((e) => e[0]).toList());