Community Patterns

Community Library Entry

-1

Regular Expression
Created·2022-10-29 13:39
Flavor·ECMAScript (JavaScript)

/
<link *.*(?: *href="([^"]*(\.png|\.ico))"| *type="(?:image\/png|image\/vnd\.microsoft\.icon|image\/x-icon)"| *rel="(?:icon|shortcut icon|apple-touch-icon)").*>
/
gim
Open regex in editor

Description

I needed a generic way to pull the shortcut icon for sites. This expression parses the html for the icon. If the icon was not found, my code checks for the "favicon.ico" in the root of the site.

Submitted by groundh0g