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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:37:05+00:00 2026-06-16T01:37:05+00:00

I cannot figure out how to accomplish this in PHP (Running 5.3.x). I have

  • 0

I cannot figure out how to accomplish this in PHP (Running 5.3.x).

I have the following string of text which I’m pulling from a txt file into a string variable:

garbage here, more garbage here, more garbage, mor ..., garbage here, more garbage here, more garbage, mor ..., more garbage here, yet more garbage

What I’m trying to get the string to look like and put back into the txt file is:

garbage here, more garbage here, more garbage, garbage here, more garbage here, more garbage, more garbage here, yet more garbage

I’m trying to figure out a way to find each occurrence of the “…” and then remove all text behind “…” until it hits the first occurrence of “,” but without any luck. Can this be done using a regex with the preg_replace function? So far, I’ve only managed to delete all the text between the first occurrence of “,” and “…” but this is not what I want. 🙁

There will be no additional commas or “…” inside the “garbage here” strings…
Also “…” does not always have a trailing “,”. It could just be “mor… more garbage here”

I only have PHP available for this task. Can it be done? I picked up a regex book this afternoon but so far I haven’t found anything that will do exactly what I’m trying to accomplish.

Any help would be greatly appreciated.

  • 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-16T01:37:07+00:00Added an answer on June 16, 2026 at 1:37 am

    You should be able to use the following regex:

    (^|,)[^,]*\.{3}
    

    Replace matches with an empty string.

    Explanation:

    (^|,)    # match a ',' or at the start of the string
    [^,]*    # match any number of characters that are not ','
    \.{3}    # match three '.' characters
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot figure out how to convert this code from C# to VB.net. It
I cannot figure out this positioning problem in Firefox. It doesn't seem to follow
I cannot figure out why this doesn't work. It seems so simple. It should
I cannot figure out how to write the following query using the DbFinderPlugin 1.2.2
I cannot figure out why I get this error during check-in. I checked in
I cannot figure out why this is not working. Can anyone explain to me
I cannot figure out how to do this. I was translating the character and
I've tried answers from other similar stackoverflow questions, but cannot figure out what i
I cannot figure out why it's throwing a NullPointerException on line 28, which is
I cannot figure out why the current location circle will not appear. I have

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.