I have this kind of SVG string that comes from a file
<svg>
<g fill="#767676" />
<path d="M15.7198 19.5836C15.4" fill="#767676" />
</svg>
And I want to remove every fill attribute from <path>
element only so it becomes like this
<svg>
<g fill="#767676" />
<path d="M15.7198 19.5836C15.4" />
</svg>
I have tried this regex, but it somehow removes the fill
attribute on other elements.
svgString.replace(/(?:<path)*fill=["|'](.*?)["|']\s*/g, '')
This part (?:<path)
to exclude the tag element not to be removed but still missing the right way to select only <path />
element and been stuck on this for some time. Hoping someone can show me the right way to do it.
Thank you