Demo attached. Click "Hyperlink Text" on the top toolbar. This uses one method, but there are others. Again, it depends on exactly what logic you use, and what exactly is the situation.

Does the text use the Hyperlink style? How - exactly - are you doing this: "I can autodetect the beginning of the URL"