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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:41:53+00:00 2026-06-05T00:41:53+00:00

$string = Apple Foo Banana … Banana Foo Other text … Apple; I have

  • 0
$string = "Apple
Foo
Banana
...
Banana
Foo
Other text
...
Apple";

I have text where single rows are duplicated after a row “…”.

The rows before and after that can be anything (“Foo”), but also be a duplicate (without “…” like “Apple”).

The “…”-row can appear multiple times without a duplicate row after it.

I only want to remove duplicated rows which have a “…” row inbetween.

In other words: Remove the line after “…” if it’s the same as above “…”

How can I match

Banana
...
Banana

to remove the duplicated row:

Banana

so the result is

$string = "Apple
Foo
Banana
...
Foo
Other text
...
Apple";

Cheers!

  • 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-06-05T00:41:54+00:00Added an answer on June 5, 2026 at 12:41 am

    If the task is to just remove the line following the line with three dots:

    echo preg_replace("/^(.+?)\r?\n(\.{3})\r?\n\\1/m", "\\1\n\\2", $string);
    

    The expression matches:

    • a whole line comprising at least one character (1)
    • three dots on a single line (2)
    • a whole line comprising at least one character (1)

    The /m modifier is used to select multi-line mode, in which ^ and $ carry the meaning of start and end of the line.

    The \\1 back reference is used to match whatever was before the three dots.

    The replacement '\\1' is needed to place back the matched line with three dots.

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

Sidebar

Related Questions

Say I have this array: $array[] = 'foo'; $array[] = 'apple'; $array[] = '1234567890;
I've come across a class that includes multiple uses of a string literal, foo.
Add a apple string when i find the first pattern of foo. Input data:
first of all, i like to say that i have read the other two
I have a menu item like this: menu.Items.Insert(0, new MenuItem { Header = String.Format(Foo
In the apple docs it states The portion is the optional string @2x and
For declaration perspective the following is allowed IList<string> list= new string[3]; list.Add(Apple); list.Add(Manago); list.Add(Grapes);
I have a string like the following: $string = <paragraph>apples are red...</paragraph> <paragraph>john is
string.insert in c# doesn't overwrite the character that is in the startindex does it?
I have a table that contains a field of comma separated strings: ID |

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.