Just tested this and it worked for me:
ta.text = ta.text.replace("\n",'');
My actual code was (cut and pasted):
var testString:String = "Hello\nWorld";
trace(testString);
testString = testString.replace("\n", '');
trace(testString);
Which yeilded the output:
Hello
World
HelloWorld
Alternatively, you can define a pattern along the lines of what you were attempting:
var pattern:RegExp = /AB\*C/;
And that works as well. The modified code would become:
var pattern:RegExp = /\n/;
var testString:String = "Hello\nWorld";
trace(testString);
testString = testString.replace(pattern, '');
trace(testString);
Note that the code above only replaces the first instance of a newline character (as you requested). Doing more would require either a recursive call to the replace function or a more sophisticated RegExp.
I hope that helps in some way,
--gMale
EDIT: given the comment discussion below, try working with one of these events, instead:
- change Dispatched when text in the TextArea control changes through user input.
- dataChange Dispatched when the data property changes.
- textInput Dispatched when the user types, deletes, or pastes text into the control.