Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(<img[^>]src="([^"]+)"[^>]?(alt="(.*?)")?[^>]?(title="(.*?)")?(style="([^"]*)")?[^>]*>)
/
g

Description

this reg will extract:

  1. "content" of SRC
  2. "content" of ALT
  3. complete width="???"
  4. "content" of style attr.

do we really need anything else to format an image?

Submitted by anonymous - 7 years ago