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

[REBOL] Re: Another question

From: greggirwin:mindspring at: 14-Feb-2002 12:43

Hi Alex, << I'm trying to figure out parse... how, for instance, would I use a parse expression to break some text into words, which are grouped with quotation marks (so you could make "foo bar" one word), but quotation marks preceded by a backslash are treated as normal text? Hello world, I said -> ["Hello world", "I", "said"] >> Do you need to escape the quotes (i.e. is there source data that contains them)? If not, parse's behavior should be pretty darn close:
>> parse {"Hello world," I said} none
== ["Hello world," "I" "said"] Hmmm. If the escapes exist, you might also just replace them:
>> parse replace/all {\"Hello world,\" I said} {\"} {"} none
== ["Hello world," "I" "said"] Though that still removes them from the text. You'll probably have to write some rules if that doesn't work for you. << Also, how would I match on a left bracket, any member of a block, and then a right bracket? Here's a pseudocode example: [ FOLLOWED BY ("red" OR "green" OR "blue") FOLLOWED BY "]" >> Can you use block parsing? REBOL can recognize things for you in mnay cases.
>> parse [[blue]] [set b block!]
== true
>> b
== [blue] --Gregg