Regular Expressions 101

Community Library

Community Library Entry

1

Regular ExpressionOpen Workspace

/
(<p[^>]*>)(.*?)(<\/p>)|(<p[^>]*>)
/
ig

Description
Created·2016-02-18 19:01
Type·Match
Flavor·PCRE (Legacy)

Strip specific HTML tags from a string—opposite of PHP's strip_tags(). Replace letter 'p' with your tag name. Using PHP preg_replace(), example: preg_replace('/(<' . $tag . '[^>]>)(.?)(</' . $tag . '>)|(<' . $tag . '[^>]*>)/i', '$2', $string);

Submitted by Zachary Beschler
Open Workspace