regex - How to extract floating point value from string in javascript? -


how extract value "-1.23" following string using js regex?

"hello-sdvf-1.23 23 4" 

this code extracts "-1"

("hello-sdvf-1.23 23 4").match(/[-]\d+|\d+/)[0]; 

you need define pattern match decimal part also.

string.match(/-?\d+\.\d+/) 

Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -