Languages
[Edit]
EN

TypeScript - check if string contains only numbers

0 points
Created by:
Frida-Timms
667

In this article, we want to show how in TypeScript using simple regular expressions, check if string contains only numbers.

Example expressions:

  1. /^[0-9]+$/
  2. /^[0-9]{1,}$/
  3. /^\d+$/
  4. /^\d{1,}$/ 

As example, we can select first one, and do some test with match() function:

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join