Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    Jquery .match function not found

    I am trying to match a url of a string and have the below code but every time I run the code it gives the following error:

    Code:
    TypeError: url.match is not a function
    [Break On This Error] 	
    
    var youtube = url.match(regex);
    Code:
    var content=$(this).val();
    var urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
    // Filtering URL from the content using regular expressions
    var url = content.match(urlRegex);
    
    //check if the url is youtube
    var regex = /youtube.com/;
    
    var youtube = url.match(regex);
    
    alert(url);
    return false;

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,608
    Thanks
    6
    Thanked 997 Times in 970 Posts
    match is nothing specific to jQuery, it’s native JavaScript. Moved to JS programming forum.

  • #3
    New Coder
    Join Date
    May 2013
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can find the function at String.prototype.match in case you were wondering.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •