I am very new to regex strings and operation. But I am trying to develop an android app that needs to replace text url (without tag) from the whole string to
<a href='$link'>$link </a>
I found that working code -
text_to_url= text_to_url.replaceAll("(<a[^>]+>)|(http(?s)://.*)", "<a href=\"$0\">$0</a>");
But as I admitted as above, I am very new to regex words and functions.
Even I can get url inside tag with that code, but it not stop at end of url (I think according to *).
Problem is, if there are 2 or more continuous link_text_urls side by side or line by line, it displaying as one link (url is 1st occurence url) .
I tried many times and searched through googles to find this bit result. But my regex knowledge can't help me to find it out.
Please kindly let me know the answer. Thank you so much for understanding my problem.
Example text -
<h3>Post Title</h3>
<p>This is a paragraph of text of the post</p>
<img src="http://imageurl">
<p>Please read more on this link</p><br/>
http://www.readmorelink.com/1212/1212post