Javascript regex only matching entire url as typing

Posted by dt on Stack Overflow See other posts from Stack Overflow or by dt
Published on 2010-05-19T22:11:52Z Indexed on 2010/05/19 23:00 UTC
Read the original article Hit count: 374

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex