I have a regular expression to detect urls from strings.
THE REGULAR EXPRESSION IS:
var urlRegex = /(https?\:\/\/|\s)[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})(\/+[a-z0-9_.\:\;-]*)*(\?[\&\%\|\+a-z0-9_=,\.\:\;-]*)?([\&\%\|\+&a-z0-9_=,\:\;\.-]*)([\!\#\/\&\%\|\+a-z0-9_=,\:\;\.-]*)}*/i;
if (urlRegex.test(text)) {
textCrawler(text);
}
This work okay but issue is that is also detects b.tech,m.tech as also valid URLs.
I call a text crawler function make a preview of the URL within the string. The issue is that if the string contains b.tech qualification etc, the text crawler gets called.
Searched few links but seems there is not a prefect regular expression for detecting URLs within the string.