Regular Expressions 101

facebook post embed code

2

Regular Expression
PCRE (PHP <7.3)

/
((<div[\s]+?id=\"fb-root\"[\s\S]+?<\/div>)*[\s]*(<script[\s\S]+?\/script>)*[\s]*(<div[\s]+?class=\"fb-post\"[\s\S]+?(<div[\s]+?class=\"fb-xfbml-parse-ignore\"[\s\S]+?<\/div>)*<\/div>)+)
/

Description

This pattern matches to the facebook post embed codes. It matches on each parts of the whole embed code individualy, and matches on the complete embed code either, but it requires minimum a fb-post div.

Submitted by kristian tanacs - 9 years ago