Regular Expressions 101

Community Patterns

Remove Width & Height Tag from iframe

0

Regular Expression
PCRE2 (PHP >=7.3)

`
<iframe\s?(?:width="(?:\d+)?")?\s?(?:height="(?:\d+)?")?\s*(.*src="https://www\.(?:youtube|vimeo)\.com.*)</iframe>
`
gm

Description

Remove width & height tage from Youtube/Vimeo embed code Useful for implementing responsive design

Submitted by Mendel Groner - 2 years ago