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

[REBOL] Re: Another question

From: stopm:mediaone at: 14-Feb-2002 21:04

----- Original Message ----- From: "Gregg Irwin" <[greggirwin--mindspring--com]> To: <[rebol-list--rebol--com]> Sent: Thursday, February 14, 2002 6:00 PM Subject: [REBOL] Re: Another question
> Hi Alex, > > << The point is, these escaped quotes should not be treated as grouping > constructs, but as normal text. So this: > > \"Hello world,\" I said > > should result in [{\"Hello} {world,\"} {I} {Said}]. >> > > OK, forgive me if I go off-track as I'm trying to understand what you > actually want to accomplish. Do you want the escaped chars to remain > unchanged, still as escaped chars, or do you want them to be translated
into
> a more normal REBOL form (i.e. unescaped :)? Using the /all refinement
with
> parse, and specifying only a space for the rule, will give you the former.
Ok, never mind, it looks like parse does exactly what I want... thanks. I did want to turn \" into " after breaking it up, however. Odd that parse recognizes backslashes for escaping quotes where the rest of REBOL uses ^ for escaping purposes....
> Sorry, I'm still confused. You can use FIND to find it but my previous > example, using block parsing, returns what it found as well. > > >> find "this is my [red] car" "[red]" > == "[red] car" > > >> parse [this is my [red] car] [some word! set b block! to end] > == true > >> b > == [red] > > Parse, in this case, finds the block for you and sets the word B to the > block it found. >
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.
> Am I getting warmer?
More or less. I've found enough of a solution. <g> Alex