Update "not working" examples.

This commit is contained in:
Christoffer Lerno
2023-09-05 14:36:17 +02:00
parent 74649ef672
commit 5a2ef79fe6
6 changed files with 17 additions and 1135 deletions

View File

@@ -4,24 +4,24 @@ import regex, stdio;
fn void main()
{
printn("Enter a story template, terminated by an empty line:");
VarString story = "";
while (1)
String story = "";
while (try String line = stdin().readline().strip())
{
VarString line = stdin.readln().strip() else break;
story = story.append(line);
story = story.append("\n");
}
Regex r;
r.initWithOptions("<.+?>", RegexOpt.GLOBAL) else unreachable;
r.initWithOptions("<.+?>", RegexOpt.GLOBAL)!!;
defer r.destroy();
foreach (RegexMatch* match : r.match(story))
{
VarString s = match.string;
printf("Enter a value for '%s': ", s[1..^2]);
string word = stdin.readln().strip() else return;
String word = stdin().readline().strip()!;
story = story.replace(s, word);
}