I need help creating a regex pattern with the following conditions:
-
It can be the empty string.
-
It can allow alphanumeric characters.
-
For special characters, only space or underscore is allowed.
-
It cannot contain consecutive underscores (_) or spaces ( ).
-
It cannot contain sequences of 3 or more underscores (_) or spaces ( ).
-
If underscore (_) or space ( ) is present, the first occurrence of _ or space must be after at least 3 characters.
-
The second occurrence of _ or space must be before at least 4 characters after the previous occurrence.
Valid patter 123_ABC_ERRR
Not Valid 123__, 123_VBV_HH_
Can someone help me frame this regex pattern in JavaScript?