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

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -