1)匹配其中一个字符 var t = "1,2,3"; t.replace(",") //"1undefined2,3" t.replace(",","") //"12,3" 2)匹配其中所有的这个字符 var t = "1,2,3"; t.replace(/,/g,"") //"123" 3)匹配数字,d 查找数字 var t = "分析范围总面积为:6654787.6平方米"; t.replace(/[^d|.]*/g,""); //"6654787.6"
1)匹配其中一个字符 var t = "1,2,3"; t.replace(",") //"1undefined2,3" t.replace(",","") //"12,3" 2)匹配其中所有的这个字符 var t = "1,2,3"; t.replace(/,/g,"") //"123" 3)匹配数字,d 查找数字 var t = "分析范围总面积为:6654787.6平方米"; t.replace(/[^d|.]*/g,""); //"6654787.6"