0

One of my switch cases checks this regex

regex_y = /[a-zA-Z0-9_]{3,20}$/;
str = 'sdsdsdsd:sdsdsdsdd.ssdsdsdsdds';

switch (true) {
    case !regex_y.test(str):
        // do anything
        return false;
        break;
// more switch cases to check
}

As the string sdsdsdsd:sdsdsdsdd.ssdsdsdsdds contains a .and a : I need the str to be defined as false but it is not. Please help me with this. What am I doing wrong?

It kind of looks like that the str is check from the beginning after unallowed characters. Same with sdsdsddsd...dsdsd....sdsdsd.

Thanks for your support!

Robin Alexander
  • 984
  • 2
  • 13
  • 29

0 Answers0