I’m trying to use javascript to find all URLs in a textarea as the person is typing (onkeyup). The problem that I’m having is in finding a regex to match the entire URL, I need it only to match all the URL’s in the text area that are complete URLs.
All of the existing regex expressions that I find through Google and through my own experiementing seem to match as soon as the user has typed the first part of the pattern. So, for example, if I’m typing and then start to type http://w, all of a sudden, it will match.
I need to find a regex that will match and return an array of all the urls that are in the textarea, while also not matching unless the person has completed typing the full URL. Hopefully that makes sense!
Thank you!
David’s comment is right.
How could you ever determine that
http://www.domain.com/whateverwas a complete URL buthttp://www.domain.com/whatwasn’t? Orhttp://www.domain.comis complete buthttp://www.domain.coisn’t? (It is, there’s a real site there).You might disallow hostnames without a
.in, but then why shouldn’thttp://tobe valid? (It is, there’s a real site there.) Not to mentionhttp://テスト.There is no possible consistent answer to the question “what is the regex to match things that look like URLs to me”.