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

[REBOL] Parsing until the end

From: fuka::fuxoft::cz at: 5-Jan-2003 21:21

Let's say I have string like this: XYhelloXYpeopleXYXYhowXYareXYyouXY XY acts as sort of separator. Now, I want to extract the string that follows "XYXY" and ends right before the last XY. If there's no "XY" at the end, don't extract anything. So, the result of: my-magic-split "XYhelloXYpeopleXYXYhowXYareXYyouXY" "XY" should be: "howXYareXYyou" ;notice there's no "XY" at the end. I thought that this could be somehow done using "end" in the parse rules but I couldn't come up with anything that would work like i intend. I had to extract everything after "XYXY" and then removing the last 2 characters if they are equal to "XY" and clear the whole string if they are not. But this doesn't seem very elegant to me. -- Frantisek Fuka (yes, that IS my real name) (and it's pronounced "Fran-tjee-shek Foo-kah") ---------------------------------------------------- My E-mail: [fuka--fuxoft--cz] My Homepage: http://www.fuxoft.cz My ICQ: 2745855