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

My regular expression needs to be able to find the strings: Visual Studio 2008
Is there a quick way to find every match of a regular expression in
What is a good regular expression that can validate a text string to make
I am trying to use regular expressions to find a UK postcode within a
Because regular expressions scare me, I'm trying to find a way to remove all
I want to use regular expressions (Perl compatible) to be able to find a
I generally stay away from regular expressions because I seldom find a good use
Is there a Regular Expression that can detect SQL in a string? Does anyone
What follows is a regular expression I have written to match multi-line pre-processor macros
Does anyone have a regular expression handy that will match any legal DNS hostname

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.