Scripts/StringFilter

Description
This is a simple helper class which allows you to specify a set of certain words / character which should not appear in a string. By default it will only filter control characters (0x00 - 0x1F). You can add custom words / characters to the exclude list.

Usage
The class generally provides two methods:

- CheckForProblems - FilterString

CheckForProblems fills a List with "Problem" structs which indicate where in the string the problematic item occurred, as well as the item from the exclude list which was found (It just stores the filter reference and the index, no garbage is generated). This can be used to inform the user about illegal characters / phrases in their input string.

FilterString will actually remove all of the exclude items from the string. You can pass a string in which case it returns the filtered string, or pass a StringBuilder. The latter might be useful when you need to do additional processing before / after the filtering. If you cache the StringBuilder you can avoid the extra garbage.