vendredi 30 avril 2021

What is the best regex for including the entire first number after a square root?

Sorry for the butchered title. I am attempting to create a calculator and need to find the first number (including negative and decimals) in a number of different cases.

One particularly difficult case includes square roots. Currently, it doesn't include anything past the first number. It is supposed to include the entire number.

Pattern for first number: "[0-9]\\d*(\\.\\d+)?(?=.*(\\-)?[0-9]\\d*(\\.\\d+)?)"

Ex."√10" returns 1 instead of 10.

Any help is appreicated! Thanks for reading this far.

Aucun commentaire:

Enregistrer un commentaire