I want to replace a number with a character at runtime like this:
Input:
ask 1234 question
Result:
ask * question
What is the best way to accomplish this?
From stackoverflow
-
You could use a regular expression.
-
Use a Regex to match a number and then do a string replace. Something along the lines of:
var str:String = "ask 1234 question"; // your string var pattern:RegExp = /\d+/ ; // a regular expression that matches numbers trace(str.replace(pattern, "*"));Look up the flex 3.0 documentation for both String and Regex. Happy coding!
-
Thanks to everyone. I tried dirkgently answer was working well.
: Thanks overcoming problemRichard Szalay : You should mark dirkgently's answer as "the answer" by clicking the tick on the left of the post.dirkgently : Good to know I've been able to help glory-grace. Thanks Richard!
0 comments:
Post a Comment