如何删除actionscript中的一部分字符串? [英] How to delete part of a string in actionscript?

查看:167
本文介绍了如何删除actionscript中的一部分字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的字符串是像BlaBlaBlaDDDaaa2aaa345我想摆脱它的子字符串是BlaBlaBlaDDD,所以操作的结果将是一个字符串aaa2aaa345如何执行这样的事情与动作?

解决方案

我只是使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆