Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace in netbeans with regular expression

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?

like image 823
Sultan Avatar asked Feb 22 '26 12:02

Sultan


1 Answers

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 $

like image 188
Adam Wolski Avatar answered Feb 25 '26 06:02

Adam Wolski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!