Search code examples
apache-flexactionscript-3textareanewline

How to check for and remove a newline (\n) in the first line of a text field in actionscript?


In the script, sometimes a newline is added in the beginning of the text field (am using a textArea in adobe flex 3), and later on that newline might need to be removed (after other text has been added). I was wondering how to check if there is a newline at the beginning of the text field and then how to remove it. Thanks in advance.


Solution

  • How about

    private function lTrimTextArea(ta:TextArea) {
      ta.text = ta.text.replace(/^\n*/,'');
    }