I came up with this function while trying to validate a filename for a script. The function will take a string and a list of characters to look for and will return true if the string contains one or more of those characters. An example would be looking for \/:*?"<>[]| as these characters should not appear in a filename, so if they exist the filename is not valid. You would call it in the following way:
checkForSpecialChar(newFilename, "\/:*?""<>[]|")