开发者

delete leading characters

I'm a noob to actionscript so this should be easy:

How do I delete leading charact开发者_运维技巧ers from a string? I have a string that contains (at times) both numeric & non-numeric characters. If I want to delete all the leading 9's, how would I do that?

var testVar:String = '999998gjek74k';

I want the testVar to be 'gjek74k'.

So far, I have (though not working):

var testVar:String = '999998gjek74k';
testVar.replace(/^0/g, "");


.replace doesn't modify the string. It returns the replaced string.

testVar = testVar.replace(/^\d+/, '');

(Also the pattern /^0/g is wrong, as commented by @santa).


Assuming you are testing the variables and not multiple lines:

private var testVar = testVar.replace(/^\d*(.+)$/,"$1");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜