World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Ladislav 14-May-2009 [2270] | a-number: [one-to-two 3 digit | non-zero-digit 0 2 digit] |
Steeve 14-May-2009 [2271] | hum.. a-number: [1 4 digit] is that not enough ? |
Ladislav 14-May-2009 [2272x2] | that allows for 0 |
as well as for 9999 | |
mhinson 14-May-2009 [2274] | that would be fine |
Ladislav 14-May-2009 [2275] | ok then, you pick what is appropriate |
Steeve 14-May-2009 [2276x2] | yep but it's an average limit that mhinson gave |
no need to be strict here, i think | |
Ladislav 14-May-2009 [2278x3] | repeated-part will not be the last thing on the line : fine, what will be the last thing on the line? |
(except for the newline character, of course) | |
will the newline character be actually there? | |
mhinson 14-May-2009 [2281] | the final wanted bit of data will be the last thing, then the end of the line because the data has been read from the file with read/lines |
Ladislav 14-May-2009 [2282x4] | how do you call the last part of the data, isn't it the same part that may repeat more than once? |
(divided by comma, of course) | |
one more thing we need to make agreement on: do we want to rely on the default whitespace handling or be more specific and say exactly where whitespace may be? | |
well, it looks, that I will have to run soon | |
Maxim 14-May-2009 [2286] | mhinson... If I can encourage you... once you will "get" it... it will all become <really> simple. you mind is just adapting to maping rules and seeing the inherent stack of what they imply. Don't give up, it will all become clear. I think we all feel the same anxiety at first. Most don't follow through, its a good thing that you persevere. :-) |
mhinson 14-May-2009 [2287] | the white space is not present in the intresting part of the data so would that suggest the default handleing would be ok? |
Maxim 14-May-2009 [2288] | you mean not using /all? |
Ladislav 14-May-2009 [2289] | probably yes |
mhinson 14-May-2009 [2290] | yes |
Ladislav 14-May-2009 [2291x2] | the rule line: [random-part repeated-part any ["," repeated-part]] just means, that at the start there is a special random-part, and then we have more repeated-part's separated by comma |
notice, that the comma isn't at the end! | |
mhinson 14-May-2009 [2293] | I dont understand why we need the repeated-part in twice? |
Ladislav 14-May-2009 [2294x2] | we didn't specify what exactly is in the repeated-part, so we can continue: repeated-part: [one-to-thirteen "/" a-range] |
repeated-part twice: good question. we stated it so, to describe the situation, when the quantity of repeated-part's is one less than the quantity of commas | |
Maxim 14-May-2009 [2296] | because of the comma (",") |
Ladislav 14-May-2009 [2297] | sorry, "one more" |
Maxim 14-May-2009 [2298] | there is no comma before the first repeated-part, basically. |
Ladislav 14-May-2009 [2299] | ok, bye, it's yours |
Steeve 14-May-2009 [2300] | Probably that would be enough: line: [random-part any [repeated-part opt #","]] But it can failed, dependening what is in repeated-part |
Ladislav 14-May-2009 [2301] | well, that does not exactly describe what mhinson said |
Maxim 14-May-2009 [2302] | steeve, that means it will not require a comma, which means the repeated part can match some wrong pattern |
Steeve 14-May-2009 [2303] | agree, but if repeated part begins and ends with digits, it will not failed |
Maxim 14-May-2009 [2304x2] | hehe its hard not to help new users here. |
but it WONT fail when they are missing, in which case your parse rules can wreak havoc. | |
Steeve 14-May-2009 [2306] | the question there is, can the comma be missing ? |
mhinson 14-May-2009 [2307] | real test data 3/1-2,3/4,3/7,3/26-30,3/34-38,3/48 3 4/1-2,4/4-13,4/15-17,4/19-21,4/23-25,4/27-28,4/30-33,4/35,4/40,4/48 4/36-39,4/41-47 35 4/29 40 4/18,4/22,4/26,4/34 999 4/3,4/14 disable 4/3,4/5,4/9,4/14,4/19,4/26,4/28,4/34,4/47 |
Steeve 14-May-2009 [2308] | but i agree that Ladislav''s rule is more secure |
mhinson 14-May-2009 [2309] | I suppose any data can get damaged, so it is better for the rules to crash & burn than hide the fact that the data is damaged |
Steeve 14-May-2009 [2310x3] | digit: charset "0123456789" alpha: charset [#"a" - #"z" #"A" - #"Z"] prefix: [1 2 digit] sufix: [some digit opt ["-" some digit]] range: [copy range! [prefix #"/" sufix] (prin ["range:" range!])] rand: [copy rand! [1 4 digit | some alpha] (prin [newline "random:" rand!])] target: [rand range any [#"," range]] parse/all inp [some [target | skip]] is that ok ? |
hmm, random is optionnal, so it should be: target: [opt rand range any [#"," range]] | |
/all has to be removed i guess | |
mhinson 14-May-2009 [2313] | I think this is what Ladislav has given us so far: alpha: charset [#"a" - #"z" #"A" - #"Z"] a-word: [some alpha] one-to-two: [#"1" - #"2"] digit: [#"0" - #"9"] non-zero-digit: [#"1" - #"9"] a-number: [one-to-two 3 digit | non-zero-digit 0 2 digit] random-part: [a-word | a-number | none] record: [random-part whitespace repeated-part any ["," repeated-part]] I understand how it relates to the data, but not how to use it to extract the bit I want.... |
Maxim 14-May-2009 [2314] | what is the data you want? (comming in late on this discussion) |
mhinson 14-May-2009 [2315] | the data is structured with a key words or a vlan number followed by ports & ranges of ports. (like 2/2,2/4-6) I want to restructure this data so I end up with port 2/2 vlan55 disabled name3 port 2/4 vlan55 disabled name4 port 2/5 vlan88 named somthing else |
Maxim 14-May-2009 [2316] | the generall concept: Once you match data, you add a parens, in which you add rebol code to execute. |
mhinson 14-May-2009 [2317] | first I am extracting the ports & ranges from the data. after that I need to recreate the actual ports and key information & do that for several types of input & colate it. |
Maxim 14-May-2009 [2318] | if you need parts of the data in your parens, the you add pointers to the data within the rules (use copy or here:) and se those within the processing parens. |
mhinson 14-May-2009 [2319] | Do you know where Ladislav was heading with his suggestions? I understood what he was saying, but not what he was going to do with the structures he recomended. |
older newer | first last |