How to remove part of a line in actionscript?

So my line is like "BlaBlaBlaDDDaaa2aaa345". I want to get rid of my substring, which is "BlaBlaBlaDDD", so the result of the operation will be the string "aaa2aaa345". How to do such a thing with ActionScript?

+3
source share
1 answer

I just used the String # replace method with a regex:

var string:String = "BlaBlaBlaDDD12345";
var newString:String = string.replace(/[a-zA-Z]+/, ""); // "12345"

This will delete all words. If you are looking for more sophisticated regular expressions , I would mess with the Rubular regular expression tester online service .

:

var newString:String = string.replace(/[^\d]+/, ""); // "12345"

, , :

var newString:String = string.replace("BlaBlaBlaDDD", "");

() , , string.replace .

+9

Source: https://habr.com/ru/post/1737765/


All Articles