java - How to detect links in a text? -


greetings have text may contain links like:

" hello..... visit on http://www.google.com.eg, , more info, please contact on http://www.myweb.com/help"

and want find , replace link following link

anyone knows how ?

and have question how website stackoverflow detects links in posts 1 , highlights them 1 can click them , visit link?

using java.util.regex can urls finding matches regexp: https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\s+)?)?)?.

import java.util.regex.*;  pattern pattern = pattern.compile("https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\s+)?)?)?", pattern.case_insensitive | pattern.dotall | pattern.multiline); matcher mymatcher = pattern.matcher(mystringwithurls); while (mymatcher.find()) {     ... } 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -