0

Below is my regex

var pattern = new RegExp(/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/);

I want this pattern to be changed to match like folder name creation restriction in windows 7 which doesn't allow below

\/:*?"<>|

How should I change my pattern to achieve this? I never wrote regex on my own as of now, I definitely will learn this soon.

Thanks.

vamsi
  • 1,488
  • 3
  • 28
  • 66
  • 1
    Actually, you need more than just disallow these chars, see [*Naming Conventions*](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx) – Wiktor Stribiżew Sep 30 '16 at 08:10
  • No need to follow the naming conventions completely, I just want to restrict above characters from entering. That's fine for me. – vamsi Sep 30 '16 at 09:17
  • Ok, so, you just want the whole string to consist of chars other than those `\/:*?"<>|`? Then use `/^[^\/:*?"<>|]*$/.test(val)` (`*` will also allow empty values) – Wiktor Stribiżew Sep 30 '16 at 09:18

0 Answers0