Using $NEST
|
Jan. 03, 2009, 03:26 AM
Post: #1
|
|||
|
|||
Using $NEST
I'm trying to write a filter that removes certain tables.
An example table: Code: <table class="maintable"> I can match this table with this code: Code: <table*class=$AV(maintable)*>*</table> The problem with that is that it doesn't work on nested tables: Code: <table class="maintable"> So I tried this: Code: $NEST(<table*class=$AV(maintable)*>,</table>) This code only removes from the first opening table tag to the first closing table tag, and not the correct closing tag for the main table. Am I using $NEST incorrectly? |
|||
Jan. 03, 2009, 07:36 AM
Post: #2
|
|||
|
|||
RE: Using $NEST
Try:
Code: <table[^>]++class=$AV(maintable)[^>]++>$INEST(<table,</table>)</table> More information on $INEST: http://proxomitron.info/45/help/Matching...html#INEST BTW, Welcome! ![]() |
|||
Jan. 03, 2009, 08:02 AM
Post: #3
|
|||
|
|||
RE: Using $NEST
(Jan. 03, 2009 07:36 AM)Kye-U Wrote: Try: That works, thanks! I thought it may have been a bug in Proxomitron, I tried it in Proximodo and it crashed 4 times in the 15 minutes I had it installed. I did read in the help file about NEST and INEST, but I didn't see that INEST also supported "inner match" (which I will need to test the tables contents before hiding it) because it wasn't used in the sample and I didn't notice it in the title with the syntax. But, why use [^>]++ instead of *? Is * greedy? Shouldn't [^>]++class and *class be the same thing, assuming there is no > before class? [^>]++class means any run of characters that isn't > up until class *class means any run of characters up until class Is that right? |
|||
Jan. 03, 2009, 08:04 AM
Post: #4
|
|||
|
|||
RE: Using $NEST
(Jan. 03, 2009 08:02 AM)Quaraxkad Wrote: But, why use [^>]++ instead of *? Is * greedy? Shouldn't [^>]++class and *class be the same thing, assuming there is no > before class? Yup, you are correct. [^>]++ is just like *, but more specific in matching all characters except >. I've ran into trouble using * instead of [^>]++, where, if the byte limit is huge, the * would actually "eat" beyond the > ![]() |
|||
Jan. 03, 2009, 08:08 AM
Post: #5
|
|||
|
|||
RE: Using $NEST
(Jan. 03, 2009 08:04 AM)Kye-U Wrote: Yup, you are correct. [^>]++ is just like *, but more specific in matching all characters except >. Ah-ha, that explains it, I usually use the max byte limit while testing. |
|||
Jan. 03, 2009, 11:11 AM
Post: #6
|
|||
|
|||
RE: Using $NEST
(Jan. 03, 2009 07:36 AM)Kye-U Wrote: Try: A slight problem with that new code... Lets say this is the table I want to match: Code: <table class="maintable"> |
|||
Jan. 03, 2009, 12:46 PM
Post: #7
|
|||
|
|||
RE: Using $NEST
<table[^>]++class=$AV(maintable)[^>]++>$INEST(<table,</table>)</table>
I'd recommend using [^>]+> instead of [^>]++> in such expressions, because gready + is faster than lazy ++. In this case however, you can skip the red code, so: Code: <table[^>]++class=$AV(maintable)$INEST(<table,</table)</table > I've used </table > (vs. </table> ) because... Code: <table (Jan. 03, 2009 11:11 AM)Quaraxkad Wrote: A slight problem with that new code... $NEST and $INEST accept an optional inner match: http://www.proxomitron.info/45/help/Matc....html#NEST Code: <table[^>]++class=$AV(maintable)$INEST(<table,*name=$AV(acell)>match me<*,</table)</table > |
|||
Jan. 03, 2009, 03:40 PM
Post: #8
|
|||
|
|||
RE: Using $NEST
Be careful when using $NEST 'cause it matches since the first opening tag it sees inside its byte limit.
Code: $NEST(<table\s,*name="inner table"*,</table >) would match: Code: <table name="outer table"> And not would match only the next code how we could wish: Code: <table name="inner table"> Trying to match the above using the code wich follows, could cause problems. So the best is what Kye-U and Sidki3k3 reccomends: Code: $NEST(<table\s[^>]++name="inner table"*,</table >) To have a better idea on how nesting works, take a look to the test window of this filter, test it with the above code: Code: [Patterns] |
|||
Nov. 14, 2009, 06:02 PM
(This post was last modified: Nov. 14, 2009 06:34 PM by PAEz.)
Post: #9
|
|||
|
|||
RE: Using $NEST
Sorry to bring up an old thread, I know its all old and boring to alot of you.
But Im trying to learn this stuff and Im having a problem figuring out why my nests arent working. Following the advise on this thread I tried a couple of things and only one worked and Im not sure why? Does Work EDIT: $NEST(<div,*id=$AV(watch-promoted-videos-container)*,</div >) <div[^>]++id=$AV(watch-promoted-videos-container)$INEST(<div,</div)</div > <div[^>]++id="watch-promoted-videos-container"$INEST(<div,</div)</div > ...and I know the last two are the same ![]() Doesnt work $NEST(<div\s[^>]++id="watch-promoted-videos-container"*,</div >) $NEST(<div\s(*>)\#,*id="watch-promoted-videos-container"*,</div >) $NEST(<div[^>]++id="watch-promoted-videos-container",</div >) ...if they do anything at all it will cut off early. Im cool with using the above working one if I have to, but that last one of the doesnt work really does look like it should work to me and Im confused. Test Code Code: <h2>Featured Videos</h2> |
|||
Nov. 14, 2009, 09:32 PM
(This post was last modified: Nov. 14, 2009 10:47 PM by JJoe.)
Post: #10
|
|||
|
|||
RE: Using $NEST
The ending needs to be unique to the beginning.
(Nov. 14, 2009 06:02 PM)PAEz Wrote: Does Work This is trying to match nests of <div to </div >. Each <div has a matching </div >. No <div to </div > consumes a <div without a </div >. (Nov. 14, 2009 06:02 PM)PAEz Wrote: $NEST(<div\s[^>]++id="watch-promoted-videos-container"*,</div >) These are trying to match nests of <div id="watch-promoted-videos-container" to </div > There isn't a nest of these. There is only one. It starts with <div id="watch-promoted-videos-container" and ends with the first </div > found, <a href="/my_quicklist">Added to <br> Quicklist</a></div> (Nov. 14, 2009 06:02 PM)PAEz Wrote: $NEST(<div\s(*>)\#,*id="watch-promoted-videos-container"*,</div >) Here the code to be matched by the inner match doesn't contain id="watch-promoted-videos-container" I'd use $INEST for things like this. HTH Edit: Added explanation for $NEST(<div\s(*>)\#,*id="watch-promoted-videos-container"*,</div >) |
|||
Nov. 15, 2009, 07:16 AM
Post: #11
|
|||
|
|||
RE: Using $NEST
THANK YOU soooooooooooo much! I get it now!
Thanks for taking the time to write such a detailed response. That was doing my head in, but with your reply and a couple of tests I get it now. INEST all the way! |
|||
Nov. 15, 2009, 03:46 PM
Post: #12
|
|||
|
|||
RE: Using $NEST
(Nov. 15, 2009 07:16 AM)PAEz Wrote: INEST all the way! Well not all the way. ![]() JJoe Wrote:I'd use $INEST for things like this. $INEST(), when the block of code begins with a rather unique string, like <div id="watch-promoted-videos-container" class="watch-promoted-container grid-view"> Otherwise, $NEST() may be best. Sometimes neither will work or is best. Have fun |
|||
« Next Oldest | Next Newest »
|