Modifying my javaScript regex to accept forward slashes -
i took regex evaluating urls works nicely want use evaluate facebook accounts. example www.facebook.com/myname.
how regex doesn't forward slash after .com.
.directive('validatetheurl', function() { // hey chaps new ng 1.3 way custom validtae stuff..... var required_patterns = [/^(?:(ftp|http|https)?:\/\/)?(?:[\w-]+\.)+([a-z]|[a-z]|[0-9]){2,6}$/]; return { require: 'ngmodel', link: function ($scope, element, attrs, ngmodel) { ngmodel.$validators.theurl = function (value) { var status = true; angular.foreach(required_patterns, function (pattern) { status = status && pattern.test(value); console.log(status); console.log(value); }); return status; }; } } })
does know how update regex?
simply append regex pattern accept forward slash after .com
[/^(?:(ftp|http|https)?:\/\/)?(?:[\w-]+\.)+([a-z]|[a-z]|[0-9]){2,6}\/[\w-]+$/];
Comments
Post a Comment