[REBOL] Re: Parse refactoring puzzle
From: AJMartin:orcon at: 30-Jul-2003 19:22
Oops! Little problem with using the wrong word, which is fixed in this
version:
[
Rebol [
Name: 'Remove_Place_Holders
Title: "Remove Place Holders"
File: %"Remove Place Holders.r"
Author: "AJ Martin"
Copyright: "Free!"
Date: 30/July/2003
Version: 1.1.0
]
Remove_Place_Holders: function [String [string!]] [Mark Start Stop] [
Mark: {!!}
parse/all String [
any [
Start: Mark thru Mark Stop: (
Stop: remove/part Start Stop
) :Stop
| skip
]
end
]
String
]
foreach [Test Goal] [
{Welcome John-Paul your address is The Vatican !!town!! Roma !!state!!
Italia}
{Welcome John-Paul your address is The Vatican Roma Italia}
{no place holders in this string}
{no place holders in this string}
{!!begin!!text!!end!!}
{text}
{!!good!holder, even if a little weird!!and some text}
{and some text}
{leaves null place-holder !!!! in output, but another function might
remove it. Either way is fine}
{leaves null place-holder in output, but another function might remove
it. Either way is fine}
] [
if Goal <> Actual: Remove_Place_Holders copy Test [
print [
"Problem!" newline
"Test:" mold Test newline
"Actual:" mold Actual newline
"Goal:" mold Goal
]
halt
]
]
print "All OK!"
halt
]
Andrew J Martin
ICQ: 26227169 http://www.rebol.it/Valley/ http://Valley.150m.com/