in a related topic, I'd like to restate/comment something said this week..
in rebol, there are usually very different ways to achieve the same goals. not just in the functions to use, but in the raw in-code ideology, of how to plug the outputs of all of the fancy series handlers. Some will optimise for code readability and sharability, others will concentrate on raw speed, and yet other solutions will tend to concentrate on code size and "denseness" this is due because in rebol, everything (well almost) is an expression and reuses the SAME basic expressions (coding) rules. So that's why I meant that knowing what you want to do, withing what parameters, actually defines what is the best course of action. now go up and learn all of those words in the dictionnary also, ALWAYS remember to check out the refinements. hey, even I revisit it now and then to refresh my memory. have fun... -MAx --- "You can either be part of the problem or part of the solution, but in the end, being part of the problem is much more fun." > -----Original Message----- > From: ML [mailto:[EMAIL PROTECTED] > Sent: Friday, April 30, 2004 6:20 PM > To: [EMAIL PROTECTED] > Subject: [REBOL] Re: Parsing out strings > > > > Thanks for the tutorial Max. > > Stuart > > > ------------Original Message------------ > > From: "Maxim Olivier-Adlhoch" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Date: Thu, Apr-29-2004 7:51 PM > > Subject: [REBOL] Re: Parsing out strings > > > > > > by using left right mid mentality... > > > > use COPY and AT > > > > so here we go: > > > > with > > > > str: "the user jsmith logged in at 4.30pm" > > > > > > > 1. "the user" > > copy/part str 8 > > > > > > > 2. "the user jsmith" > > copy/part str 15 > > > > > > > 3. "jsmith" > > copy/part at str 10 6 > > > > > > > 4. "jsmith logged in at 4.30pm" > > copy at str 10 > > > > > > > 5. "logged in at 4.30pm" > > copy at str 17 > > > > > > now I'd say that there is a good chance that there is a > better "SOLUTION" to the problem, given a better problem description. > > > > if the ordering of the log file is extremely constant or if > some words always describe the following data, then I'd rather do: > > > > blk: parse/all str " " > > > > >> user: third blk > > == "jsmith" > > > > > > > > >> priviledge: select blk "the" > > == "user" > > > > > > >> user: select blk priviledge > > == "jsmith" > > > > > > >> time: to-time replace select blk "at" "." ":" > > == 16:30 > > > > > > > > >> action: pick intersect blk ["print" "mailed" "logged" > "browsed"] 1 > > == "logged" > > > > I used pick, in case no matching action was found, in wich > case the word 'first would crash, whereas 'pick returns none instead. > > > > > > >> sub-action: select blk first action > > == "in" > > > > here again, if the select fails, then select returns none. > > > > > > now if we replace the string by: > > > > "the sysadmin root mailed fred at 9.00am" > > > > then all the rules still hold, yet the copy/all code > earlier, becomes completely useless... you see in rebol, the > problem is not in solving but in analysis. analysing the > data patterns. By doing thid properly (and knowing a few > rebol words), rebol's expressive power can be fully harnessed. > > > > > > extending the above could be that the user name is > optional, like so: > > > > str: "the sysadmin mailed fred at 9.00am" > > > > > > The following expression would return a default user if > none was given: > > > > users: ["root" "mary" "john"] > > blk: parse/all str " " > > > > priviledge: select blk "the" > > > > user: either (offset: find users select blk priviledge) [ > > first offset > > ][ > > select ["user" "guest" "sysadmin" "root"] priviledge > > ] > > > > > > > > have fun :-) > > > > HTH!!!! > > > > -MAx > > --- > > "You can either be part of the problem or part of the > solution, but in the end, being part of the problem is much more fun." > > > > > > > -----Original Message----- > > > From: ML [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, April 29, 2004 5:56 PM > > > To: [EMAIL PROTECTED] > > > Subject: [REBOL] Parsing out strings > > > > > > > > > > > > I am pretty new to REBOL and am having a bit of trouble > > > getting my head around how to parse out strings from lines I > > > am reading in from session logs. > > > > > > I am looking at "clear find" and "remove/part" and things > > > like this but I am getting very confused as to what to use > > > when, I am more of a left$, mid$, right$ kind of guy. > > > > > > Perhaps I can illustrate. > > > > > > Suppose the line I am parsing says: > > > "the user jsmith logged in at 4.30pm" > > > > > > Can you give me a clue what I would use to parse in each of > > > these circumstances where the desired text is: > > > > > > 1. "the user" > > > 2. "the user jsmith" > > > 3. "jsmith" > > > 4. "jsmith logged in at 4.30pm" > > > 5. "logged in at 4.30pm" > > > > > > Obviously the jsmith part would change for each line so the > > > parsing out would need to probably base it on looking for > > > "the user " and then looking for the next space after that > > > which should be after the name. > > > > > > Anyone give me a clue? > > > > > > Thanks > > > > > > Stuart > > > > > > -- > > > To unsubscribe from this list, just send an email to > > > [EMAIL PROTECTED] with unsubscribe as the subject. > > > > > > > > > > -- > > To unsubscribe from this list, just send an email to > > [EMAIL PROTECTED] with unsubscribe as the subject. > > > > > > > > > > -- > To unsubscribe from this list, just send an email to > [EMAIL PROTECTED] with unsubscribe as the subject. > > -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.