I need to prevent user from entering the following set of chars: ~ " # % & * : < > ? / \ { | } .
Important is that, anything else will be allowed, but only the characters shown above will be forbidden.
Currently, I'm using the following regex but this does also forbid for example ! sign.
private static folderRegex = /^[A-Za-z0-9_-]+[ßüÜöÖäÄ\w]*$/;
Just put the set of characters in an inverse set and add a ^ and a $ to stretch the pattern to the full length of the input.
private static folderRegex = /^[^~"#%&*:<>?\/\\{|}]+$/;