RosettaCodeData/Task/Mad-Libs/Zkl/mad-libs.zkl
2017-09-25 22:28:19 +02:00

9 lines
370 B
Text

story,line,re:=Data(),"",RegExp("(<[^>]+>)");
do{ line=ask("Story: "); story.write(line,"\n") }while(line);
while(re.search(story,True)){
z,ml,N:=re.matched,z[1],z[0][1]; // z=( (0,6),"<name>" )
s:=ask("Text to replace ",ml," with: ");
while(Void!=(n:=story.find(ml))){ story[n,N]=s } // replace all <names>s
}
println("-----------------");
story.text.print();