I'm a beginner with jQuery.
I simply want to pass a block of text to a function and return an array of urls contained within.
"I need to grab a url like http://www.something.com from text, and if therearemore.com then grab those too".
Any help? Is there a .GetUrl()?
Note: I suck with regular expressions!
The jQuery Wiki Text plugin (http://www.kajabity.com/jquery-wikitext/) includes Regular Expressions to find URls in text which can be used for the purpose.
So, you asked for a function - well here it is:
Hope it helps.
RegExp is probably the way to go, and this should do the trick for you:
See demo →
You will have to use a regular expression. Try:
If you aren't good with regular expression, I'd recommend taking a look at this online tool for building them: http://rubular.com/.
Try this to get all type of links
http://aaa.aaa.aaa
www.aaa.aaa
www.aaa.aaa/aaa
string.match(/(www|http|https|ftp|ftps)?:?/?/?[a-zA-Z0-9-.]+.[a-zA-Z]{2,3}(/\S*)?/gi);