i have string who is
String hello = "test test {Brian} have you {Adam} always and {Corner} always";
want to make list string who is taking who have {string} output :
List<String> data = ["{Brian}","{Adam}","{Corner}"];
its that possible in dart ?
i dont know what to use
CodePudding user response:
You can achieve this by using 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());