如何删除actionscript中的一部分字符串? [英] How to delete part of a string in actionscript?
问题描述
我只是使用 String#用正则表达式替换方法:
var string:String =BlaBlaBlaDDD12345;
var newString:String = string.replace(/ [a-zA-Z] + /,); //12345
这将删除所有单词字符。如果你正在寻找更复杂的正则表达式,我会乱在网上 Rubular 正则表达式测试人员。
这将删除所有非数字字符:
var newString:String = string.replace(/ [^ \d] + /, );如果你知道你想删除的确切的字符串,那么只需要这样做:/ /12345
var newString:String = string.replace(BlaBlaBlaDDD,);
如果你有一个你想删除的子串的列表(数组)每个 string.replace
方法。
So my string is something like "BlaBlaBlaDDDaaa2aaa345" I want to get rid of its sub string which is "BlaBlaBlaDDD" so the result of operation will be a string "aaa2aaa345" How to perform such thing with actionscript?
解决方案 I'd just use the String#replace method with a regular expression:
var string:String = "BlaBlaBlaDDD12345";
var newString:String = string.replace(/[a-zA-Z]+/, ""); // "12345"
That would remove all word characters. If you're looking for more complex regular expressions, I'd mess around with the online Rubular regular expression tester.
This would remove all non-digit characters:
var newString:String = string.replace(/[^\d]+/, ""); // "12345"
If you know the exact string you want to remove, then just do this:
var newString:String = string.replace("BlaBlaBlaDDD", "");
If you have a list (array) of substrings you want to remove, just loop through them and call the string.replace
method for each.
这篇关于如何删除actionscript中的一部分字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!