Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

~
<url>\s* (?> (?> (?><lastmod>\s*(?<mod>[^<]+)\s*</lastmod>) | (?><changefreq>\s*(?<freq>\w+)\s*</changefreq>) | (?><priority>\s*(?<prio>[01](?>\.\d{1,2})?)\s*</priority>) )\s* ){0,3}\s* <loc>\s* (?<uri>[^<]+)\s* </loc>\s* (?> (?> (?><lastmod>\s*(?<mod>[^<]+)\s*</lastmod>) | (?><changefreq>\s*(?<freq>\w+)\s*</changefreq>) | (?><priority>\s*(?<prio>[01](?>\.\d{1,2})?)\s*</priority>) )\s* ){0,3}\s* </url>
~
gxuJ

Description

Match all XML sitemap url records with all known fields

See Sitemaps XML format for details.

Submitted by Slava Krampetz - 3 years ago