But when we are changing something inside tag (in between < and >), it's getting messed up. For example, if I'm changing src of the img tag, the result will be <img <del>src='rat.jpg'</del><ins>src='fox.jpg'</ins> />

So what I'm looking for a function to pass my string and

if there is any <del> or <ins> found after '<' and before '>' of a tag, the <ins> or <del> should move to before '<'

and

if there is any </del> or </ins> found after '<' and before '>' of a tag, the </ins> or </del> should move to before '>'