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

[REBOL] Re: Parsing until the end

From: joel:neely:fedex at: 5-Jan-2003 16:12

Hi, Frantisek, Frantisek Fuka wrote:
> 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. >
ffsplit: func [ str [string!] mid [string!] end [string!] /local start ][ if found? start: find str mid [ if end = find/last start: skip start length? mid end [ copy/part start (length? start) - length? end ] ] ] which behaves as
>> ffsplit "XYhelloXYpeopleXYXYhowXYareXYyouXY" "XYXY" "XY"
== "howXYareXYyou" HTH! -jn-