How to search and validate plain texts (where it starts with http AND ends with .aspx) to be a valid hyperlink in a page body content?

Posted by syntaxcode on Stack Overflow See other posts from Stack Overflow or by syntaxcode
Published on 2014-08-19T04:11:57Z Indexed on 2014/08/19 4:20 UTC
Read the original article Hit count: 89

Filed under:
|
|

My web page content is populated by a plain text that is retrieved from a CDATA format - plain text data.

This is the site http://checksite.apsx to get information.

For more information, visit http://moresites.com/FAQ/index.html or search the site.

Now, my goal is to convert this plain text to a valid hyperlinks. I've used a javascript code that does the conversion - /((http|https|ftp):\/\/[^ ]+)/g; , but sometimes if there are multiple words, it captures an invalid URL.

My question: Is there a way to strictly capture any string that starts with "http" AND ends with ".html" or "aspx" will be converted into a valid hyperlink?

it should look like this -

This is the site http://checksite.apsx to get information.

For more information, visit http://moresites.com/FAQ/index.html or search the site.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex