Regex for removing an attribute from svg/html/xml

Another one that is really just a note for my future self;

I’m currently working with large svg files and they are littered with paths that have inline styles defined. I need to strip these and just control the style with css or dynamically with code.

So, using Sublimetext for this, I can use the following regex expression in the find and replace:

style\=\”(?<=”)[^”]+(?=”)\”

Replace ‘style’ for whatever other attribute you want to find.

I so rarely have a need for regex I’ve still not learned it, so this is just something harvested off the web that actually works with the flavour of regex that sublime uses.

Leave a Reply

Your email address will not be published. Required fields are marked *