I'm using the jQuery validation engine to parse my form data: https://github.com/posabsolute/jQuery-Validation-Engine
What would be the regex to validate a twitter URL (including the http://twitter.com part) Eg:
http://twitter.com/barackobama
or
http://twitter.com/#!/barackobama
You can verify your Twitter card in 3 easy steps: Choose the card type. Add it to your site using correct metatags. Verify the URL through the Twitter card validator for a successful log message.
Match the given URL with the regular expression. In Java, this can be done by using Pattern. matcher(). Return true if the URL matches with the given regular expression, else return false.
URL regular expressions can be used to verify if a string has a valid URL format as well as to extract an URL from a string.
RegEx validation is essentially a syntax check which makes it possible to see whether an email address is spelled correctly, has no spaces, commas, and all the @s, dots and domain extensions are in the right place.
/(?: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_]+)/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With