Detect links from text and then return a html form

In chat view I recently got to know that the chat view support html and hence one of my problem is solved. But, Now I want that the message sent by the sender which have some links like http://example.com, https://example.com or simply example.com which are intended to be clicked upon to open them in webviewer. I use firebase, so I want that the links of these types should be replaced by http://example.com so that the chat view can treat them as hyperlinks and i can use webviewer or activty starter to open these links in user’s browser. But, I have no idea on how to achieve this.

Hi :wave:

To convert your links into clickable links, you could use RegEx.
Using this extension and the following Regular Expression, so you can find links in your text (even if they do not contain any protocol) and then add the http:// or https:// protocol to it:

/^(http://www.|https://www.|http://|https://)?[a-z0-9]+([-.]{1}[a-z0-9]+).[a-z]{2,5}(:[0-9]{1,5})?(/.)?$/g

You can test this pattern here: Url checker with or without http:// or https:// - Regex Tester/Debugger

Thank you very much,
Markus

You asked the same question here, please do not double post

I think…No, I have not asked…???

Yes another user asked the same thing, my mistake :slight_smile:

You can use regex extension by @Kevinkun

first to detect links as shown here and then to replace by …

image

No problem :slightly_smiling_face:

1 Like