I am currently using this regex:
str.match(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);
To check if a string is a URL in my application. I check this so I can render the URL in <a> tags. But in some situations, the user's string will be a filename that I don't want to be converted into a URL.
Does anyone have a regex pattern that would give me the the following result?
isUrl(www.google.com) // true
isUrl(google.com) // true
isUrl(http://google.com) // true
isUrl(https://google.com) // true
isUrl(1235_myfile.wav) // false
I've searched on StackO and can't find any questions that match this specific case. Thanks