Thursday, August 16, 2012

REGEX (javascript) – Allow alphanumeric characters with special characters not in the first position

I\’d like to devise a regex expression that allows alphanumeric characters, as well as other characters as long as they\’re not in the first position. Examples:



VALID: Test
VALID: Hello123
VALID: 456 Hi
VALID: 456-789
VALID: Hi-777
VALID: 333-Hi
VALID: Hello-There
VALID: What\'s Up
VALID: Hello#Goodbye

INVALID: -Hello
INVALID: &Goodbye


Here\’s my starting point, which only allows alphanumeric:



/[a-zA-Z]+/






Rating: 1 out of 5 based on 3 ratings



The post REGEX (javascript) – Allow alphanumeric characters with special characters not in the first position appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/regex-javascript-allow-alphanumeric-characters-with-special-characters-not-in-the-first-position.html

No comments:

Post a Comment