# Extract a Number from a String with JavaScript

DevFeed: [Extract a Number from a String with JavaScript](<https://devfeed.tech/articles/extract-a-number-from-a-string-with-javascript-37487.md>)

Original publisher: [Read original article](<https://davidwalsh.name/javascript-extract-string>)

Author: David Walsh

Published: 2024-01-16T11:48:41Z

Content type: tutorial

Language: en

Sources: [David Walsh](<https://devfeed.tech/sources/david-walsh.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Regular expression](<https://devfeed.tech/topics/regular-expression.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [HTML](<https://devfeed.tech/topics/html.md>)

Tags: [html](<https://devfeed.tech/tags/html.md>), [input](<https://devfeed.tech/tags/input.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [javascript-quick-tips](<https://devfeed.tech/tags/javascript-quick-tips.md>), [numbers](<https://devfeed.tech/tags/numbers.md>), [quick-tips](<https://devfeed.tech/tags/quick-tips.md>), [regular-expressions](<https://devfeed.tech/tags/regular-expressions.md>), [string](<https://devfeed.tech/tags/string.md>)

## AI overview

This tutorial explains how to extract numbers from strings in JavaScript, particularly user input from HTML form fields, using regular expressions.

## Source excerpt

User input from HTML form fields is generally provided to JavaScript as a string. We've lived with that fact for decades but sometimes developers need to extract numbers from that string. There are multiple ways to get those numbers but let's rely on regular expressions to extract those numbers! To employ a regular expression to [...] The post Extract a Number from a String with JavaScript appeared first on David Walsh Blog.