I have a text as follows
For further details, please contact abc.helpdesk@xyz.com
I want to replace the email ID mentioned in the above text by <a href "abc.helpdesk@xyz.com">abc.helpdesk@xyz.com</a>
So that the email ID would become a clickable object when the above text would be presented on web page
So far I have tried out following
text = 'For further details, please contact abc.helpdesk@xyz.com'
email_pat = re.findall(r'[\w\.-]+@[\w\.-]+\.\w+',text)
email_str = ' '.join(email_pat) #converts the list to string
text_rep = ext.replace(email_str,'<a href "email_str">email_str</a>')
The above code replace the email string but instead of creating hyperlink it actually does the following
For further details, please contact <a href "email_str">email_str</a>
Is there any way to tackle this?
Edit
When I am using the above solution in Flask, on frontend I am getting the desired result (i.e. email ID becomes clickable, urls become clickable). But when I click on this I am being redirected to the localhost:5002
instead of opening the Outlook. localhost:5002
is where my Flask App is being hosted.
Even for the url also it is not working. I am using the following code to make the url string clickable.
text = text.replace('url',f'<a href "{url_link}">{url}</a>'
The above code is making the usr string clickable, but upon clicking it is being redirected to localhost:5002
Is there any change I need to make in app.run(host=5002)
method?