Naming things at runtime

I am working on the game where the player will be allowed to name certain animals, like you could name the dinosaurs in “Aotearoa”. Changing the printed name is of course trivial, but I can’t for the life of me figure out how to get the parser to understand a variable text as an object. Example 294 in Chapter 16.9 of the documentation seems kinda like this, but that only works with enumerated values. All I need is for an object to have a text variable, and then have the parser understand this text as the object.
Am I missing something really obvious here?

You’ll want example 305 in chapter 16.5 or even better example 408 in chapter 19.8.

Thanks! Example 408 works like a charm, except for one thing: I want to support multiple names, so an object can be named something like “John Doe”, and the player can then refer to it as either “John” or “Doe”. The method in example 408 only matches the full string.

Maybe this thread and this post might help? It’s kind of terrible overkill, and probably terrible code, but is sort of on the same subject.

A saner thing to do would probably be to give the animals the properties “first name” “middle name” and “last name,” slot each word of the name the player gives them into one of those properties, have all those be understood as the animal in question, and forbid the player from giving the animals a name comprising more than three words.