如何查找字符串中的数字 js

2022-05-08

以下示例是关于Javascript中包含如何查找字符串中的数字 js用法的示例代码,想了解如何查找字符串中的数字 js的具体用法?如何查找字符串中的数字 js怎么用?如何查找字符串中的数字 js使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。

[英]:how to find number in string js源码类型:Javascript
// To find a number in a string
const str = "sdfh0d5f6"
const result = str.match(/\d+/g)

console.log(result)
// ['0', '5', '6']

本文地址:https://www.itbaoku.cn/snippets/785493.html