So I'm trying to split a string which contains operator.
Here is the example :
var string= "12+13+45-78*45/91=100"
(how can i achieve this using dart)
var result = [12,+,13,+,45,-,78,*,45,/,91,=,100]
Does anyone have a solution?
So I'm trying to split a string which contains operator.
Here is the example :
var string= "12+13+45-78*45/91=100"
(how can i achieve this using dart)
var result = [12,+,13,+,45,-,78,*,45,/,91,=,100]
Does anyone have a solution?
You can do it with something like:
RegExp exp = new RegExp(r"\d+|\+|-|\*|/|=");
String str = "12+13+45-78*45/91=100";
Iterable<Match> matches = exp.allMatches(str);
var list = matches.map((m) => (m.group(0)));
print(list);
it will print:
(12, +, 13, +, 45, -, 78, *, 45, /, 91, =, 100)
ints as that's what the OP's intended output implies.