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

removing \r\n from string

Guest
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.
TOPICS
ActionScript

Views

2.9K

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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," ");

Votes

Translate

Translate

Report

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