Regular Expressions 101

Community Patterns

facebook post embed code

1

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.

Submitted by kristian tanacs - 9 years ago