Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141780

Regex to not allow '.', '_', '-' at String Start or End and should not have consecutive '.' and the rest all special characters should not be allowed

$
0
0

the output should be like

.test_test1-test - INVALID
test2_test-test. - INVALID
_test.test-test- - INVALID
test.test-test - VALID
test._test-test - INVALID

The current expression that i have is mentioned below

/^[a-zA-Z0-9](?![_.-]?[^\na-zA-Z0-9]{2}).*?[a-zA-Z0-9]$/gim

Viewing all articles
Browse latest Browse all 141780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>