Post Reply 
Counting Run-On's
May. 23, 2013, 11:48 PM (This post was last modified: May. 23, 2013 11:52 PM by ProxRocks.)
Post: #1
Counting Run-On's
is there a way to count [using LST(count) perhaps] how many TIMES a "repeat" is 'repeated'?

ie, let's say my filter match line is this, "([.-])\1+{4,2048}"...

is there a way for the filter replace line to tell me if there were FOUR dots back-to-back or if there were FORTY dots back-to-back?

something where the web page will show ...[+1] if there were FOUR dots or will display ...[+37] if there were FORTY dots...
and in turn will display ...[+1834] if there were originally 1837 dots...
Add Thank You Quote this message in a reply
May. 24, 2013, 12:41 AM (This post was last modified: May. 24, 2013 02:12 AM by JJoe.)
Post: #2
RE: Counting Run-On's
Something like

Code:
[Patterns]
Name = "Example 1"
Active = FALSE
Limit = 2048
Match = "([.-])+{3}"
        "(([.-]$TST(($GET(n)+)=$LST(Count)|*)$SET(n=$GET(i)))+{1,2045})\1"
Replace = "....\1"
          "[+$GET(n)]\r\n"
          "$SET(n=)$SET(i=)"

If you don't need n

Code:
[Patterns]
Name = "Example 2"
Active = FALSE
Limit = 2048
Match = "([.-])+{3}"
        "(([.-]$TST(($GET(i)+)=$LST(Count)|*))+{1,2045})\1"
Replace = "....\1"
          "[+$GET(i)]\r\n"
          "$SET(i=)"

Note that $LST(Count) uses \0.

HTH

Edit:Limit=2048
Add Thank You Quote this message in a reply
May. 24, 2013, 01:59 AM
Post: #3
RE: Counting Run-On's
looks good, will test in the morning...

i'm curious as to the limit being 2045...
while my original 2048 is arbitrary, with the first three being caught by the first match line and 2045 being caught by the second line, if we did need to catch 2048, wouldn't the limit line be 2048 and the second line still be 2045?
Add Thank You Quote this message in a reply
May. 24, 2013, 02:11 AM
Post: #4
RE: Counting Run-On's
(May. 24, 2013 01:59 AM)ProxRocks Wrote:  wouldn't the limit line be 2048 and the second line still be 2045?

You are correct. And it was 2048 and 2045 at one time, lol. I must be doing (or trying to do) too many things at once.

Have fun.
Add Thank You Quote this message in a reply
May. 24, 2013, 11:07 AM
Post: #5
RE: Counting Run-On's
the "with n" version works like a charm...

without the n, the FIRST match for the filter will display the wrong count (perhaps the "i" from another filter)...


much appreciated...
Add Thank You Quote this message in a reply
May. 24, 2013, 09:46 PM
Post: #6
RE: Counting Run-On's
(May. 24, 2013 11:07 AM)ProxRocks Wrote:  without the n, the FIRST match for the filter will display the wrong count (perhaps the "i" from another filter)...

Correct again. When sidki used that format he initialize the value of i. I didn't see where he finally cleared it, if ever.

You could

Code:
[Patterns]
Name = "Example 2a"
Active = FALSE
Limit = 2048
Match = "([.-])+{3}$SET(i=)"
        "(([.-]$TST(($GET(i)+)=$LST(Count)|*))+{1,2045})\1"
Replace = "....\1"
          "[+$GET(i)]\r\n"
          "$SET(i=)"

Thanks
Add Thank You Quote this message in a reply
May. 24, 2013, 11:02 PM
Post: #7
RE: Counting Run-On's
how much of an advantage is there to go "without n" versus the "with n" version?
Add Thank You Quote this message in a reply
May. 25, 2013, 02:44 AM (This post was last modified: May. 25, 2013 02:44 AM by JJoe.)
Post: #8
RE: Counting Run-On's
That depends on the number of loops. With n each loop executes $SET(n=$GET(i)). The n version could be milliseconds slower.

Given 2048 dots:
i version profiles at 18.247024 (milliseconds)
n version profiles at 28.947115 (milliseconds)

They fail in the same amount of time.

Probably seems silly to most but it is something that I consider.
Add Thank You Quote this message in a reply
May. 25, 2013, 03:00 AM
Post: #9
RE: Counting Run-On's
cool...
i'll run with the newer i version...

thanks again...
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: