between square brackets inc. square brackets
Moderator: General Moderators
-
Zugzwangle
- Forum Newbie
- Posts: 1
- Joined: Mon Aug 30, 2010 3:50 am
between square brackets inc. square brackets
hi, what would the regex be, to find all content between square bracket including the brackets themselves? for example I want to find and delete [color=blue:2cd68fd71f] and [/color:2cd68fd71f]
Re: between square brackets inc. square brackets
Code: Select all
'/\[[^\[\]]+\].+\[\/[^\[\]]+\]/'Or if you want to distinguish between different things in between the brackets, you can be more specific like this, which works for the example you gave:
Code: Select all
'/\[color=[a-z]+:[a-f0-9]{10}\].+\[\/color=[a-z]+:[a-f0-9]{10}\]/i'
Last edited by MichaelR on Mon Aug 30, 2010 5:21 am, edited 1 time in total.
Re: between square brackets inc. square brackets
(\[.*?\])
Micheal as far as I can tell he's not trying parse bbcode. He's trying to match the bbcode itself, not the text encapsulated within bb tags. Like a strip tags function made for removing unwanted bbcode formatting.
Micheal as far as I can tell he's not trying parse bbcode. He's trying to match the bbcode itself, not the text encapsulated within bb tags. Like a strip tags function made for removing unwanted bbcode formatting.
Re: between square brackets inc. square brackets
Ah, I see. My mistake.