J
Jane Doe
Hello,
[Since this question is actually a regex used in the open-source
filtering application Privoxy, it's a bit off-topic here, but this is
the closest ng I found about using regex, so please bear with me ]
Although I read the O'Reilly book on regex along with the "The
Filter File" part of the documentation and various links, I can't
figure out why Privoxy searches for patterns in greedy mode, regarless
of my use of either the U switch, or the ? limiter after a counter
like .* or .+ .
Here's the starting HTML, the Privoxy filter, and the output:
1. I just want to remove the complete "Item2" row, as shown :
<html>
<head>
</head>
<body>
<table>
<tr>
<td>
Item1
</td>
</tr>
<!-- I want to remove this part -->
<tr>
<td>
Item2
</td>
</tr>
<!-- until this point -->
</table>
</body>
</html>
2. Here's the Privoxy config I used :
Default Action
{+filter{acme}}
www.acme.com
Filter
FILTER: acme
s|<tr>.+Item2.+</tr>||sigU
# DOESN'T WORK EITHER, SAME RESULT s|<tr>.+?Item2.+?</tr>||sig
3. Here's what Privoxy generates:
<html>
<head>
</head>
<body>
<table>
</table>
</body>
</html>
=> Ie. the U switch is ignored. Removing the U switch and using the
manual ? ungreedifier doesn't work any better.
Thx much for any tip
JD.
[Since this question is actually a regex used in the open-source
filtering application Privoxy, it's a bit off-topic here, but this is
the closest ng I found about using regex, so please bear with me ]
Although I read the O'Reilly book on regex along with the "The
Filter File" part of the documentation and various links, I can't
figure out why Privoxy searches for patterns in greedy mode, regarless
of my use of either the U switch, or the ? limiter after a counter
like .* or .+ .
Here's the starting HTML, the Privoxy filter, and the output:
1. I just want to remove the complete "Item2" row, as shown :
<html>
<head>
</head>
<body>
<table>
<tr>
<td>
Item1
</td>
</tr>
<!-- I want to remove this part -->
<tr>
<td>
Item2
</td>
</tr>
<!-- until this point -->
</table>
</body>
</html>
2. Here's the Privoxy config I used :
Default Action
{+filter{acme}}
www.acme.com
Filter
FILTER: acme
s|<tr>.+Item2.+</tr>||sigU
# DOESN'T WORK EITHER, SAME RESULT s|<tr>.+?Item2.+?</tr>||sig
3. Here's what Privoxy generates:
<html>
<head>
</head>
<body>
<table>
</table>
</body>
</html>
=> Ie. the U switch is ignored. Removing the U switch and using the
manual ? ungreedifier doesn't work any better.
Thx much for any tip
JD.