0
removing \r\n from string

/t5/animate-discussions/removing-r-n-from-string/td-p/322943
Mar 26, 2009
Mar 26, 2009
Copy link to clipboard
Copied
Hello, how do I remove the "\r\n" newline characters from a
string in AS3 ?
I can do it in Flex using StringUtil trim, but that is not available in Flash.
Thanks for any help.
I can do it in Flex using StringUtil trim, but that is not available in Flash.
Thanks for any help.
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/animate-discussions/removing-r-n-from-string/m-p/322944#M8799
Mar 26, 2009
Mar 26, 2009
Copy link to clipboard
Copied
To remove all you can use the String's replace() method. To
actually trim (only remove trailing and starting whitespace) you'd
have to look for a RegExp that does exactly that in combination
with the replace() method
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/animate-discussions/removing-r-n-from-string/m-p/322945#M8800
Mar 27, 2009
Mar 27, 2009
Copy link to clipboard
Copied
Try something like this which replaces returns with a space:
//grep to globally (gi) look for returns
var returns:RegExp=/\r/gi;
//your input text
var str:String="the text";
//return the clean text
str.replace(returns," ");
//grep to globally (gi) look for returns
var returns:RegExp=/\r/gi;
//your input text
var str:String="the text";
//return the clean text
str.replace(returns," ");
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

