I have a string in javascript like `#box2' and I just want the '2' from it.
(我在javascript中有一个字符串,如`#box2',我只想要它的'2'。)
Tried:
(尝试:)
var thestring = $(this).attr('href');
var thenum = thestring.replace( /(^.+)(wd+w)(.+$)/i,'$2');
alert(thenum);
It still returns #box2 in the alert, how can I get it to work?
(它仍会在警报中返回#box2,我该如何让它工作?)
It needs to accommodate for any length number attached on the end.
(它需要适应末端附加的任何长度编号。)
ask by user1022585 translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…