Regular Expressions 101

Community Patterns

1...34567...902

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 - 4 years ago