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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:56:43+00:00 2026-06-05T05:56:43+00:00

In a string I have somthing like this: [select|blog] Some text some text some

  • 0

In a string I have somthing like this:

[select|blog]
    Some text some text some text
[/select]

more text more text more text

[select|information]
    Some text some text some text
[/select]

Now using preg_match I would like the function to:

  • get the text between the [select] tags
  • change it
  • insert it back into the string
  • remove the select tags

So in the end it will become something like this:

Changed text1 Changed text1 Changed text1

more text more text more text

Changed text2 Changed text2 Changed text2

Hope you guys can help me out. Thanks! 🙂

  • 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-05T05:56:45+00:00Added an answer on June 5, 2026 at 5:56 am

    This regex will get you started

    \[.*?](.*?)\[.*?]
    

    Put the option on that allows the dot . to match new line

    The text inside the brackets is in group 1

    I’m coming from the .NET world so I would tackle this with a function that I can let get executed after each match.
    The input of this function is the match. Here you can get to group 1 if you need to access to it and rewrite or put your new content.

    I just read in the comments that the equivalent in php is preg_replace_callback()

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

Sidebar

Related Questions

I have something like this hard-coded: private string[,] m_RolesForUser = new string[,] { {John,President,Chair},
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())
I have written something like this pretty easily in C# ( string GetUrl(new {
I have a string containing something like this Hello bla bla bla bla ok,
I have two tables which looks something like this Table Queue int ID; string
I have string: text and something and something like f213 @@ -1,9 +1,11 @@
I have to write an query something like this select * from table where
I am playing with making a blog. I would like to have several types
Using the oledb provider. Query is something like this: SELECT appid FROM table WHERE
I have a query that is basically like this: SELECT foo FROM bar where

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.