Reputation: 3277
I have brackets that contain data as so:
[vc_tag][/vc_tag]
Where tag could be any of about 30 pieces of text.
I need some regex that will remove any brackets that contain vc_
I have this, but it removes all instead of just vc_
:
$data = preg_replace('/\\[(?>[^\\]]*)\\]/', '', $content);
I also tried:
$data = preg_replace('/\\[(vc_[^\\]]*)\\]/', '', $content);
which removes the opening [vc_tag]
but not the closing [/vc_tag]
This is written in PHP by the way.
Upvotes: 4
Views: 492
Reputation: 89547
You can try this:
$data = preg_replace('~\[/?vc_[^]]*]~', '', $content);
Upvotes: 4