Home > regexp > Regexp to split XML Tags into one tag per line

Regexp to split XML Tags into one tag per line

September 20th, 2010 Leave a comment Go to comments

I was working with an XML file which was all jumbled onto one line. I wanted to split the XML tags out to make them human readable.

This is the Regexp I used puts a carriage return between all >< but not ></

%s#><\([^/]\)#>\r<\1#g

This neatly separates the tags into one tag per line. Note the use of regex memory .

Categories: regexp Tags:
  1. No comments yet.
  1. No trackbacks yet.