Post Reply 
Matching decimal/fraction ranges
Feb. 25, 2012, 04:49 PM
Post: #4
RE: Matching decimal/fraction ranges
the rabbit hole got deeper and deeper... after hours, my brain lost concentration. (also causing clumsy sentence structure in this post)

An idea:
if you usually leave browser Javascript enabled, javascript should do math very conveniently (but I don't know js). otherwise this is as far as i followed the rabbit holes. And maybe the test examples are useful.

My previous reply is the 0.nnnn case. i actually tested the expression in the Bounds with only * in Match.
Code:
(0|).([#7:9]$LOG(W7:9)|[#75:99]$LOG(W75:99)|[#750:999]$LOG(W750:999)|[#7500:9999]$LOG(W7500:9999))

above includes small edit, for when real world css might omit leading 0
example .8888 match by .nnnn

0.nnnn case seems ok.



same testing of the 1.nnnn case.
Code:
1(.(([#0:1001]$LOG(C#0:1 )|2$LOG(C2 )([#0:401]$LOG(C#0:4 )|5$LOG(C5 )([#0:*]$LOG(C#0:* )|$LOG(Cnothing ))))|[#0:*]|)|[#0:*]|)

This filter tests only the 1.nnnn case
Code:
Name = "FontReSizeCss[sbk20120225T2a 1.nnn was1c"
Active = TRUE
Multi = TRUE
Limit = 24
Match = "([^0-1]+)\1"
        "1(.(([#0:1001]$LOG(C#0:1 )|2$LOG(C2 )([#0:401]$LOG(C#0:4 )|5$LOG(C5 )([#0:*]$LOG(C#0:* )|$LOG(Cnothing ))))|[#0:*]|)|[#0:*]|)"
        ""
        "([^0-9]+)\5"
Replace = "\113px"


examples of possible css numerical variations.
1.2501 2 5 #0:*
1.24 #0:1
1.2400001 2
1.249 #0:1
1.2499 2
1.24999 2

1 yes
1. yes
1.0 #0:1
1.000 #0:1
1.0000 #0:1
1.00000 #0:1
1.00009 #0:1
1.0009 #0:1
2 [No Match]
2. [No Match]
2.0 [No Match]
3 [No Match]


I tested bounds expression alone, in Bounds. (use only an * in Match)



Then assembled bounds, 1.nnnn, and 0.nnnn
Code:
Name = "FontReSizeCss[sbk20120225T1c"
Active = FALSE
Multi = TRUE
Bounds = "font-size: ([0]+.[7-9]|[#1](.([0-2]|)|))*++ em"
Limit = 24
Match = "([^0-1]+)\1("
        "1(.(([#0:1001]$LOG(C#0:1 )|2$LOG(C2 )([#0:401]$LOG(C#0:4 )|5$LOG(C5 )([#0:*]$LOG(C#0:* )|$LOG(Cnothing ))))|[#0:*]|)|[#0:*]|)"
        "|"
        "(0|).([#7:9]$LOG(W7:9)|[#75:99]$LOG(W75:99)|[#750:999]$LOG(W750:999)|[#7500:9999]$LOG(W7500:9999))"
        ")([^0-9]+)\5"
Replace = "\113px"

Then i found a problem. i hadn't earlier tried this numerical example, which the assembled filter fails to reject:
1.999
used this to test the assembled filter:
font-size:1.999 em

I then tested example with only Bounds and with only 1.nnnn
They also fail to reject.


My suspicion:
[#0:*]
sub expressions were intended to eat excess trailing digits.
But i think these subexpression(s) have too much freedom.
For the fail example font-size:1.999 em
the [#0:*] allow the overall Match to act like
1*++em
or act like
1.*++em

i think those trailing digit subexpressions
[#0:*]
need to be moved to inside some OR cases, so the [#0:*] cannot eat trailing digits of some examples, which would cause filter to reject.


i think the Bounds has similar problem. It eats trailing digits for too many examples. This would be the part:
|)|))*++ em
and for the same example 1.999


Sometimes I thought treating digits as characters [0-4] would be better than treating digits as numerical ranges [#0:4] But I think variations of few or many digits would cause same difficulty to match . Some examples:
1
1.
1.2
1.29999


i think all of this demonstrates how easy to get into a mess. Sad
Add Thank You Quote this message in a reply
Post Reply 


Messages In This Thread
Matching decimal/fraction ranges - zoltan - Feb. 25, 2012, 12:30 AM
RE: Matching decimal/fraction ranges - sbk - Feb. 25, 2012, 09:49 AM
RE: Matching decimal/fraction ranges - sbk - Feb. 25, 2012 04:49 PM
RE: Matching decimal/fraction ranges - sbk - Feb. 25, 2012, 05:34 PM
RE: Matching decimal/fraction ranges - JJoe - Feb. 25, 2012, 10:16 PM
RE: Matching decimal/fraction ranges - zoltan - Feb. 26, 2012, 03:40 AM

Forum Jump: