JavaScript
Article

jQuery extract numbers from string

By Sam Deering

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

function getId(str)
{
    return str.replace(/[^d.,]+/,'');
}

No Reader comments

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in JavaScript, once a week, for free.