React calculator: check if any value exists in string

Is there anyway I could check if more than one value exists in a string? My idea is to have only two conditions: a) if there´s no decimal, add it; b) if there´s an operator (±*/) followed by a number from 0 to 9, add it. The decimal gets added only when one of those two conditions are met. What string method could I use?

maybe try match. Pass it a regular expression and it returns the matches in an array.

Thanks for the reply.

This code works: it only allows you to enter one decimal if there wasn´t one previously, or if the pattern matches the regex. Problem is, if the second condition is met (there´s an operator followed by a number), it allows me to enter as many decimals as I want. Any idea on how I can limit it to just ONE after a match is found (and after any matches)?