Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

removing \r\n from string

Guest
Mar 26, 2009 Mar 26, 2009
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.
TOPICS
ActionScript
2.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 26, 2009 Mar 26, 2009
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 27, 2009 Mar 27, 2009
LATEST
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," ");
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines