str_replace() function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| function str_replace(search, replace, string) {
while(string.indexOf(search) != -1) {
var array = string.split(search);
string = array.join(replace);
}
return string;
}
// Example
var str = 'testing\r\nthis';
trace(str);
var newString = str;
newString = str_replace("\r", '', newString);
newString = str_replace("\n", ' ', newString);
trace(newString); |
This entry was posted
on Friday, May 22nd, 2009 at 9:21 am and is filed under ActionScript 3.0 Snippets.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.