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

[REBOL] Re: Parse refactoring puzzle

From: antonr::iinet::net::au at: 31-Jul-2003 16:14

This version modifies the string in place (in case you have a very long string): clear-place-holders: func [str [string!] /local start ] [ probe parse/all str [ any [ ;(print "----") to "!!" start: ; move to first mark, set start to current index ;(prin index? start ?? start) 2 skip thru "!!" ; skip a character 2 times, move index beyond next mark finish: ; set finish to current index ;(prin index? finish ?? finish) :start ; set index back to start (remove/part start finish) ; remove text from start to finish ] to end ] str ] ; test foreach [example goal][ {hello !!name!! anton, your phone is !!phone!! 123456} {hello anton, your phone is 123456} {head!!abcd!efgh!!tail} {headabcd!efghtail} {head! !abcd!efgh!!tail} {head! !abcd!efgh!!tail} ][ print ["---^/" example] print clear-place-holders copy example ] Anton.