I’ll post this here since it’s what I ended up with. This code creates a lowercase version of the player’s command to be used for text matching. If there are multiple commands in the same line, it splits off just the first of the commands.
It turns out the regular expression matching line that I had borrowed from this post matches “then” but not “THEN” which is one reason I decided to put the command text in lowercase before doing any matching. Since I don’t need to print out the “current command” anywhere, it shouldn’t need to match the player’s capitalization.
I’m also blocking commas elsewhere in my code, so those can’t be used as command separators.
(Edit: If a period is used in a command for some other reason than command separation–for example, as part of a person’s title–I guess that could make the “current command” inaccurate, but I don’t anticipate that happening with this game, or causing any dire consequences if it does, since I’m using the “current command” text mostly for disambiguation purposes.)
Include version 2/260110 of Before Processing a Command by Daniel Stelzer.
The current command is a text that varies.
Last before processing a command (this is the find the current command rule):
let lowercase-player's-command be "[player's command]" in lower case;
[If multiple commands separated by "." or "then" are detected, find the text that comes before the first separator:]
if lowercase-player's-command matches the regular expression "(.+?)(\.|\bthen\b)(.+)":
now the current command is the text matching subexpression 1;
otherwise:
now the current command is lowercase-player's-command;
[say "**Player's command: [Player's command][line break]";
say "**Current command: [Current command][line break]";]