I have this regular expression that tokenizes calculator input strings like 12+3.4x5
to 12
,+
,3.4
,x
,5
The regular expression used is
\d+\.?\d+|[\+-÷x]
I get an unexpected match with ^
and letters.
I have this regular expression that tokenizes calculator input strings like 12+3.4x5
to 12
,+
,3.4
,x
,5
The regular expression used is
\d+\.?\d+|[\+-÷x]
I get an unexpected match with ^
and letters.
Regex solution, although there's probably a cleaner way of writing this if someone could point it out?
(\d+\.?\d+|\d+|(\+|-|÷|x))