Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
<img src=([a-zA-Z0-9_\-\s\.\"=\/:%,()]*class=\"[a-zA-Z0-9_\-\s\.\"=\/:%,()]*lazy[a-zA-Z0-9_\-\s\.\"=\/:%,()]*)
/
gm

Description

This regex converts text like this: <img src="fonts/608be7747d9cf15397b0d112_Logo-v3-01.svg" alt class="nav-logo lazy">

TO: <img data-src="fonts/608be7747d9cf15397b0d112_Logo-v3-01.svg" alt class="nav-logo lazy">

Submitted by Suman Maharjan - 3 years ago