这就是单干的痛苦阿...
'A1 A2 A3 A4 5A 66' 想变成 "1 2 3 4 5A 66"
javascript里有办法一次正则去掉 数字在后的A,然而数字在前的A不去掉?
'A1 A2 A3 A4 5A 66' 想变成 "1 2 3 4 5A 66"
javascript里有办法一次正则去掉 数字在后的A,然而数字在前的A不去掉?
1
qinxg Sep 12, 2013
[^A]
|
2
felix021 Sep 12, 2013 正则入门不是只要30分钟吗....痛苦在哪?
|
3
yushiro Sep 12, 2013 chrome 的console模式下运行:
'A1 A2 A3 A4 5A 66'.replace(/A([0-9])/g,'$1') |
6
Mutoo Sep 12, 2013 可以用零宽断言,找到后面的数字的A
"A1 A2 A3 A4 5A 66".replace(/A(?=\d)/g,"") |
7
yakczh Sep 12, 2013 <script>
var a='A1 A2 A3 A4 5A 66' ; a=a.replace(/A(\d\s)/g,"$1"); //alert(a); document.write(a); </script> |
8
solos Sep 12, 2013 可以用环视,'A1 A2 A3 A4 5A 66'.replace(/(?=A\d)A/g, '')
|
9
Ever Sep 12, 2013 'A1 A2 A3 A4 5A 66'.replace(/\bA/g,'')
|
10
Alexisused Sep 12, 2013 'A1 A2 A3 A4 5A 66'.replace(/A(\d)/g, '$1')
|
11
yyife Sep 12, 2013 var s = 'A1 A2 A3 A4 5A 66' ;
var reg = /A(\d+)/g; console.log(s.replace(reg,function(w){return w.substr(1,w.length);})); 可以随意处理 |