0

I have a textField in my calculator app and I am splitting the whole input in the end to separate numbers and operators. For getting numbers I am using this:

QStringList nums = displayVal.split(QRegularExpression("[\+\-\/\*]"));

The problem is that it is also splitting at "." for some reason. I am not that familiar with Regular expressions so it the fault is probably in my regular expression. So what should I do to split at "+", "-", "*" and "/" only?

Example text: 4+2/3.5

Should get [4, 2, 3.5]. Of course the values will be in QString.

Ayush Singh
  • 1,409
  • 3
  • 19
  • 31

0 Answers0