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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:05:50+00:00 2026-05-28T03:05:50+00:00

Ok, trying to change a string like so: [topic]=2[board]=2 to return this instead: [topic][board]=2

  • 0

Ok, trying to change a string like so:

[topic]=2[board]=2

to return this instead:

[topic][board]=2

In the above situation, I’ll be working with a string variable that equals [topic] and another string variable that equals [topic]=2[board]=2

But this needs to be done for all situations… More examples follow:

profile[area]=account[u]=1

should return this:

profile[area][u]=1

In the above situation, I’ll be working with a string variable that equals profile and another string variable that equals profile[area]=account[u]=1

Another example:

moderate[area]=groups[sa]=requests

Should be this:

moderate[area][sa]=requests

In the above situation, I’ll be working with a string variable that equals moderate and another string variable that equals moderate[area]=groups[sa]=requests

And another:

[board]=1

Should return:

[board]=1

In the above situation, I’ll be working with a string variable that equals [board] and another string variable that equals [board]=1

Basically, what it needs to be able to do, is to get rid of the text in between ONLY the text that are between the brackets of only the first and second brackets (if the second bracket exists only). It should not effect any third, fourth, 5th brackets. Only the first and second brackets.

Can someone please give me a hand with this?

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-05-28T03:05:50+00:00Added an answer on May 28, 2026 at 3:05 am

    Here’s a regular expression that works:

    (?<=\])\=[^\[\r\n]*(?=\[)
    

    http://regexr.com?2vn71

    That \r\n might need to be changed to a \Z in PHP, since you won’t be dealing with line breaks, but rather with the end of a string.

    So, something like:

    preg_replace("/(?<=\])\=[^\[\Z]*(?=\[)/", "", $target);
    

    Edit:

    Here’s a breakdown of what’s happening here:

    (?<-\]) Make sure there’s a [ character before the matched expression

    \= Match a = character

    [^\[\Z]* Match all characters until you find a [ or the end of the string (\Z)

    (?=\[) Make sure there’s a [ after the matched expression

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

Sidebar

Related Questions

My php is weak and I'm trying to change this string: http://www.example.com/backend.php?/c=crud&m=index&t=care ^ to
I have a string variable like the one below. I'm trying to split it
I have a string like this that I need to parse into a 2D
I am trying to combine two SortedDictionaries , change the result to a List<KeyvaluePair<string,string>>
After finding the fastest string replace algorithm in this thread , I've been trying
I'm trying to compile a bit of code that looks something like so: (examples
Attempting something like public string MyText { get {return lbl.Text;} set {lbl.Text = value;}}
I'm trying to split a string formatted like Bananas|,|Bananas|||Bananas|Oranges|,|Bananas|||Bananas|Oranges|||Bananas|Oranges|Green Apples|,|Bananas|||Bananas|Oranges|||Bananas|Oranges|Red Apples|,|Bananas|||Bananas|Oranges|||Bananas|Oranges|Pears with a regex,
I am trying to compare a string and a char like below : char
I'm trying to temporarily change the contents of a div on hover, using this

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.