I have a very specific question for JavaScript:
I have the following string:
var prueba ="Hola mundo 5.26"
I need to extract the decimal number from that string. How can this be done?
Thank you very much
I have a very specific question for JavaScript:
I have the following string:
var prueba ="Hola mundo 5.26"
I need to extract the decimal number from that string. How can this be done?
Thank you very much
Try this regular expression
var resultado = prueba.match(/[0-9]*\.[0-9]*/g)
You can get the number within a string like this:
var prueba = "Hola mundo 5.26";
var numero = parseFloat(prueba.match(/\d+(\.\d+)?/g));
Good luck!