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

[REBOL] Re: Another question

From: g:santilli:tiscalinet:it at: 15-Feb-2002 11:04

At 03.04 15/02/02, Alex wrote:
>Okay, that's nice, but I want to parse real text, not a block. I'm just >going to use repeated replace statements here (since the original goal was >to replace [red] with an escape character followed by "[31m" for example), >but I was hoping to go through the various color tags ([red], [green], >[blue] etc.) and search through the remainder of the text after finding a >tag regexp-style for the next tag. That way, no time would be wasted >re-scanning through the entire string to find new codes... but a repeated >replace is okay as well. C'est la vie.
Does this help? (Escape sequences are not the real ones I think, I just used them as an example.)
>> normal-text: [to "["] >> escape-seq: [mark1: "[" copy color ["red" | "blue" | "green"] "]" mark2:] >> colors: ["red" "^(1B)[31m" "green" "^(1B)[32m" "blue" "^(1B)[33m"] >> text-to-parse: {
{ This is some [red]text followed by some [blue]text, and so on[green]... { }
>> parse text-to-parse [some [normal-text escape-seq (mark2: change/part mark1 select colors color mark2) :mark2]] >> text-to-parse
== { This is some ^[[31mtext followed by some ^[[33mtext, and so on^[[32m... } Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r