JS 提取字符串中的数字

var str = "example12str933"
var res1 = str.replace(/\D/g, '') // 第一种替代所有非数字 \D
var res2 = str.replace(/[^\d]/g, '') // 第二种替代所有非数字 ^\d
var res3 = str.replace(/[^0-9]/g, '') // 第三种替代所有非 0-9 ^0-9
var resArry = str.match(/\d+/)[index] // 数组
// res1 12933
// res2 12933
// res3 12933
// resArry [12, 933]
                    JS 提取字符串中的数字var str = "example12str933"var res1 = str.replace(/\D/g, '') // 第一种替代所有非数字 \Dvar res2 = str.replace(/[^\d]/g, '') // 第二种替代所有非数字 ^\dvar res3 = str.replace(/[^0-9]/g, '') // 第三种替代所有非 0-9 ^0-9var resArry = str.match(/\d+/)[index] // 数组// res
				
const filterNum = (str, isDot = false) => { //isDot代表是否去除全部小数点,默认不去除只保留第一个小数点 if (str == '' || str == undefined || str == null) { return } else { str = str.toString(); let temNum = str.replace(/[^\d.-]/g, ''); //去除数字(不包括小数点
[removed]=function(e){ var text=document.getElementById("only"),pattern=/\d/,//pattern匹配字母上的数字键 pattern2=/(9[6-9])|(10[0-5])|3(7|9)/,//pattern2匹配小键盘上的数字键和左右方向键 EventHandle={},event=e||window.event;//一个处理事件的对象       //当网页加载的时候,进行判断,对事件处理对象进行定义属性, function regExp (value){ value = value.replace(/[^\d.]/g,""); //清除“数字”和“.”以外的字符 value = value.replace(/^\./g,""); //验证第一个字符数字而不是. value = value.replace(/\.{2... * @throws PatternSyntaxException public static String StringFilter(String str) throws PatternSyntaxException { //定位符用来描述字符串或单词的边界,^ 和 $ 分别指字符串的开始与结束,\b 描述单词的前或后边界,\B 表示..