I7: Sanitizing Descriptions

Can anyone suggest a good regex or two to sanitize Inform 7 object names and descriptions provided through a web form? It doesn’t need to be bulletproof, just good enough to cleanup the most likely problems. Substituting ’ for " is the most obvious thing I can thing of. Anything else?

What exactly are you doing? Accepting English names of objects, and generating I7 source code which should contain those objects?

The safest way to do this is to convert spaces to dashes. That eliminates all your preposition problems (“for”, “to”, etc).

You should limit the input to a known alphabet (A-Z, 0-9, space/dash). Punctuation may cause problems.

Some single words are probably verboten. “Is”, for example. Unfortunately I don’t think there’s a complete list anywhere.

I’m using description texts too, so eliminating spaces and all punctuation is not an option. Plus I’d like the generated code to look reasonably idiomatic and not overly “computery”. Ultimately the generated source will just be a small handful of rooms and objects, so the probability of weird naming clashes popping up is fairly low (I hope). Are there any other basic transformations besides double quotes to single anyone can think of to transform the kind of text a naive user might enter into something that will compile?

I’m not sure what you mean. You’d want to apply that transformation to the name and not to the description, obviously.