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 🙂
Here’s a regular expression that works:
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:
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