Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Perl is to stupid to understand this 1 liner.

From: petr:krenzelok:trz:cz at: 14-Dec-2001 14:41

Hi, Carl used parse without any need to define a rule, e.g. parse some-string none will give you a block of strings separated by space But why not to use rule? Because of having everything on one line? OK, with rebol - it is pretty legal to have whole script on one line (if you don't use comments of course :-), so: digits: charset "0123456789" spacer: #"-" tel-num: [3 digits spacer some [digits | spacer]] parse/all text [some [start: tel-num end: (print copy/part start end) | skip]] 555-1212 800-555-1111 123-4576 987-6543 111-1111 == true I know that tel-num rule allows for some 999------, but that is sufficient for our demo ... Just put on one line, shorten word names, and replace rebol code in parens to get your result ... If someone finds easier solution (e.g. iteration based) for my string replacement, cool then :-) hide-it: func [s e][ l: length? copy/part s e remove/part s e insert/dup s # l) parse/all text [some [start: tel-num end: (hide-it) | skip]] ; <----- clear and readable, isn't it? :-) Well, on the other hand not so straightforward as your Perl example ... Cheers, -pekr-