Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 911661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:14:49+00:00 2026-05-15T17:14:49+00:00

What is the regular expression to find the first newline ( \n ) in

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:14:50+00:00Added an answer on May 15, 2026 at 5:14 pm

    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.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a regular expression, but can't find. Parsing a text file looking
I need to parse and replace text using gsub and a regular expression. A
I am trying to first find a div using a regular expression (since its
I have to find the first url in the text with a regular expression:
How can I update this regular expression to find and replace not just /news/
I'm trying to find a regular expression that would allow me replace the SRC
I have the following regular expression to find word in text and highlight them
is it possible to get a regular expression that do: find first occurence of
I've been trying to do the following using VBs Regular Expression object but could
how do i return after the first match of regular expression? (does the Matcher.find()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.