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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:25:53+00:00 2026-05-26T20:25:53+00:00

Im trying to replace the following string in php: 2011.11.12 20:06,Teal’c Ostus,Solid Pyroxeres 46521,Pyroxeres

  • 0

Im trying to replace the following string in php:

2011.11.12 20:06,Teal'c Ostus,Solid Pyroxeres 46521,Pyroxeres

With:

2011.11.12 20:06,Teal'c Ostus,Solid Pyroxeres,46521,Pyroxeres

NOTE: There are 5 comma separated values here

Time, Character, Item Type, Quantity, Item Group

Note there are still to be some spaces left behind such as between date and time and first and last name and item with multiple words in its name.

Additionally, it cannot replace the \r and \n as there are many rows like the one above

  • 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-26T20:25:54+00:00Added an answer on May 26, 2026 at 8:25 pm

    Here is the regex for Search:

    (\d{4}\.\d{2}\.\d{2}\s\d{2}:\d{2},[^,]*,\D*)\s(\d{5},.*)
    

    And the regex for replace

    $1,$2
    

    Explanation:

    The Regex for search

    (       Begin a numbered capture group (Nameless and accessed via index)  
    \d{4}   Means: capture digits with exact 4 repititions  
    \.      Capture a dot (You have to escape it with a backslash, if not it means capture all  
            characters except linefeed)
    \d{2}   Capture 2 digits
    \.      Capture a dot
    \d{2}   Capture 2 digits
    \s      Capture 1 whitespace
    \d{2}   Capture 2 digits
    :       Capture a colon
    \d{2}   Capture 2 digits
    ,       Capture a comma
    [^,]*   Capture everything except a comma with 0 to infinity repititions
    ,       Capture a comma
    \D*     Capture everything except a digit with 0 to infinity repititions
    )       Close first capture group
    \s      Capture a whitespace
    (       Begin a numbered capture group
    \d{5}   Capture 5 digits
    ,       Capture a comma
    .*      Capture everything except a linebreak
    )       Close second capture group
    

    The Regex for Replace

    $1      Insert capture group number 1
    ,       Insert a comma
    $2      Insert capture group number 2
    

    I hope that explains a little bit the (helpful but sometimes confusing) “magic” of regular expression. A good tool to design and test regular expressions is called Expresso and can be find here. If you want an online help and regex library with expression tester, you’ll find it here

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

Sidebar

Related Questions

I'm trying to replace c++ with <b>c++</b> in the following string: Select the projects
I'm trying to do a replace on the following string prototype: I&amp;lsquo;m singing &amp;
I am trying to replace some words from a string and use following code
I've been trying to replace to following string using the following... var r =
I'm trying to translate the following slugify method from PHP to C#: http://snipplr.com/view/22741/slugify-a-string-in-php/ Edit:
I'm trying to remove (just replace it with ) the following String: <script type=text/javascript>
I am trying to replace following statement with the lambda expression: List<ABC> l =
I'm trying to run the following commands: replace -x must A2input.txt replace -x a
I'm trying to replace all link href's in a large string with a different
I am trying to remove following tag from string. [caption id=attachment_9 align=alignleft width=137 caption=test][/caption]

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.