Regex to validate a twitter url

I'm not familiar with jQuery but if it uses standard regex it would be something like this:

http://twitter.com/(#!/)?[a-zA-Z0-9_]{1,15}

This bit (#!/)? is to make the #!/ optional, and this [a-zA-Z0-9_]{1,15} is because Twitter usernames can contain letters (upper or lowercase), numbers and underscores and can be up to 15 characters in length.


/(?:http:\/\/)?(?:www\.)?twitter\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-]*)/

with optional using https or add www e.g

http://twitter.com/example
https://twitter.com/example
http://www.twitter.com/example
https://www.twitter.com/example

is valid


You mean

/http(?:s)?:\/\/(?:www\.)?twitter\.com\/([a-zA-Z0-9_]+)/

Tags:

Jquery

Regex