Regular Expressions 101

Community Patterns

Community Library Entry

3

Regular Expression
PCRE (PHP <7.3)

/
\[([^\[\]]++|(?R))*+\]
/

Description

Drupal7 Media Element in node body - A regex to match the media module square bracketted token/element for embedde images in node body. Use case - using the body text trimmed in a meta description - need to remove the media element as well as strip tags.

Submitted by iAugur - 9 years ago