What is the regular expression to find the first newline (\n) in a text (used to find and delete the newline)? I’m using the regular expression in ActionScript and tried
ta.text = ta.text.replace(/\n*/,'')
but it doesn’t seem to work
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just tested this and it worked for me:
My actual code was (cut and pasted):
Which yeilded the output:
Alternatively, you can define a pattern along the lines of what you were attempting:
And that works as well. The modified code would become:
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: