JavaScript
Article
By Sam Deering

jQuery extract numbers from string

By Sam Deering

Quick jQuery code snippet to extract numbers from string using a replace regex method.

--ADVERTISEMENT--

function getId(str)
{
    return str.replace(/[^d.,]+/,'');
}
Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account