I want a regular expression that could be used to find the following lines:
<rect width='10px' height ='20px'/>
<rect width='20px' height ='22px'/>
<circle radius='20px' height ='22px'/>
and replace them by the these lines:
<rect width='10px' height ='20px'></rect>
<rect width='20px' height ='22px'></rect>
<circle radius='20px' height ='22px'></circle>
Thank you .
I don’t think regex is the right tool for this job, but something like this will “work” some of the time.
The above Java snippet prints:
The regex is this (see also on rubular.com):
Essentially we try to capture what we hope is a tag name in group 1, and everything else until the
/>in group 2, and use these captured strings in our substitution.References