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

  • Home
  • SEARCH
  • 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 6761427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:11:22+00:00 2026-05-26T14:11:22+00:00

Hi I want to search about some characters (or word) in text using JavaScript

  • 0

Hi I want to search about some characters (or word) in text using JavaScript and remove the line that starts this characters/word..

example

remove the lines that start with ( He ) ..

input

Hello world, 
He like cats and dogs
Bye bye

output

Hello world, 
Bye bye
  • 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-26T14:11:23+00:00Added an answer on May 26, 2026 at 2:11 pm

    You can find the pos of the “He ” using the indexOf method and then get the position of the next line-break to remove that line using the substring method.

    var someString = "Hello world,\n" +
        "He like cats and dogs\n" +
        "Bye bye";
    
    var pos = someString.indexOf('He ');
    var nextLineBreak = someString.indexOf('\n', pos);
    
    var firstPart = someString.substring(0, pos);
    var secondPart = someString.substring(nextLineBreak +1);
    
    var finalString = firstPart + secondPart;
    alert(finalString);
    

    jsFiddle here : http://jsfiddle.net/zw2Gh/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to search each line for the word FAILED , then print the
I spend some days to search solution about this trouble : I have an
I'm doing a webpage about apples (the fruit), I want to include Google search
I want to search for files containing DOS line endings with grep on Linux.
I want to search a directory for all files that match a certain pattern.
I want to search the program >> that is by which you append to
When we enter a word in Google image search, a page is returned. This
I have some text I want to linkify, which I can reasonably do with
I want to send a query to Wikipedia. The Reponse contains some informations about
This is super handy for some problems: >>> re.search('(?P<b>.b.).*(?P<i>.i.)', 'abcdefghijk').groupdict() {'i': 'hij', 'b': 'abc'}

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.