Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(<(?P<tag1>\w+)>)\n(?'tag2'[\w\<\>.]+)\n<\/(?P=tag1)>
/
gm

Description

This is my attempt at using Regex to "pretty print" a poorly formatted xml file. So far it can indent the contents of a tag a single layer deep

Submitted by Josh Clark - 4 years ago