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 7530071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:48:39+00:00 2026-05-30T04:48:39+00:00

I have to remove a set of lines that start with a marker and

  • 0

I have to remove a set of lines that start with a marker and end with another marker.
I want to find all such pieces of text and remove them using regex. The problem is, regex only matches one line at a time. How should I proceed?

  • 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-30T04:48:41+00:00Added an answer on May 30, 2026 at 4:48 am

    In most regex parsers, you can add a s to the end as a “dotall” modifier. This will make . match anything, including newlines (which it normally does not match).

    But the dotall modifier does not exist in javascript. Instead, you have a “pseudo-dotall” modifier by using a predefined character class and its negation — collectively these two things will match anything, including a newline. The canonical example is [\s\S] (match anything that is whitespace or anything this is not whitespace = match anything). But any character class and its negation will do (e.g. [\d\D] will also work).

    So in your case, if your start token is S and your end token is E you can do this:

    string.replace(/S[\s\S]*?E/g, '')
    

    Two notes: I am using the g or global modifier to replace all instances. And in [\s\S]*?, the ? means “match the shortest sequence” (non-greedy). That way it really will be instances of delimited tokens rather than treating all the stuff between the first begin token and last end token as a single token.

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

Sidebar

Related Questions

I have a text file and I want to remove some lines that contain
I have a cart.Lines List and want to remove all items where quantity ==
I have a set of characters I want to remove from a string :
I have a set of urls for example http://t3.gstatic.com/images?q=tbn:ANd9GcRfLZhH0jpyUJxGtsiHcldUPiNQsosLdR9xgcYqVWyRWGYS4qtt http://feeds.feedburner.com/~r/DrudgeReportFeed/~4/zSLWG4ybmjw I want to remove
I have set up a remote Mercurial (Hg) repository that holds a large Java
I have set up an app that is registered for remote notifications. - (void)application:(UIApplication*)application
I have to remove quotes from a relatively large text file. I have looked
I have to remove all ul within li except the current li . <ul>
I have a busy indicator that I want to show when my application is
I have an iCal (Calendar) alarm that is set to go off everyday. It

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.