This script is a function that removes any bad characters from the value of a parameter.
A typical use would be a form insertion or update page where before you insert the field values, you remove any bad characters so that they don't perform operations that they shouldn't, and also as a back up if your Javascript form validations are bypassed by one means or another.
You can replace the RegExp pattern with one of the RegExp's in the RegExp section of the snippets exchange as you desire. Use this snippet to wrap your field call with the function.