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

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

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