zhoradk zhoradk - 2 years ago 74
PHP Question

Regular expression to find group of tags for PHP

Please help me to write regular expression to find group of tags


[et_pb_codeadmin_label="Code"] [tag] [/et_pb_code]

if it is inside some other tags like



[et_pb_codeadmin_label="Code"] [tag] [/et_pb_code]


And only 3 thing same all the time

[et_pb_...can be any text here


[/et_pb_...can be any text here

I have this

[et_pb_section fullwidth="on" specialty="off"]
[et_pb_fullwidth_code admin_label="Fullwidth Code"]

I need to get only this

[et_pb_fullwidth_code admin_label="Fullwidth Code"][tag][/et_pb_fullwidth_code]

Answer Source

You can use something Like:

preg_match_all('%(\[et_pb_.*?\]){2}\s+(\[et_pb_.*?\] \[tag\] \[/et_pb_.*?\])\s+(\[/et_pb_.*?\])%i', $subject, $result, PREG_PATTERN_ORDER);
echo $result[1][0];


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download