I am not very good at regular expression. I was trying to replace a text in Netbeans for a large HTML document. There are several tags like these:
<canvas width="62" height="23" style="width: 62px; height: 23px; top: 1px; left: 1px; ">
<canvas width="62" height="23" style="width: 62px; height: 23px; top: 1px; left: 1px; ">
<canvas width="67" height="23" style="width: 67px; height: 23px; top: 1px; left: 1px; ">
I want to replace these tag with a space or null value to remove them.
I tried with
^<canvas width="[0-9]*" height="[0-9]*" style="width: [0-9]*px; height: [0-9]*px; top: [0-9]*px; left: [0-9]*px; ">
but it didn't help.
Can anyone give me a solution?
Using regular expressions to parse html is bad idea, but if you have to...
Try using regex groups:
^<canvas width="([0-9]*)" height="([0-9]*)" style="width: ([0-9]*px); height: ([0-9]*px); top: ([0-9]*px); left: ([0-9]*px); ">$
So you can refer to first group by $1 etc.
Remember about multiline flag if you are using ^ and $
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With