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
2010-08-31 19:50:12
for me, \r worked instead of \n.
2010-08-31 20:09:46
@user use `[\n\r]+` - it'll work in all cases.
Amarghosh
2010-09-01 03:58:59