views:

63

answers:

1

In flex, how to remove empty lines in text area?

+2  A: 

Assuming you mean unwanted blank lines created by gratuitous carriage returns, here's one way. I made it verbose for clarity, but you could reduce it to a single line if you wanted.

private function stripLinesFromTextArea (textArea:TextArea) : void {
  var txt:String = textArea.text;
  var re:RegExp = /\n+/g;
  txt = txt.replace(re,"\n");
  textArea.text = txt;
}
Robusto
for me, \r worked instead of \n.
@user use `[\n\r]+` - it'll work in all cases.
Amarghosh