0

I need some help from JavaScript developers

I have a chat box where I send their own message with the input, and they may send a link along with the message, and I want to put the links that are sent next to the messages in a tag so that they can be clicked.

for example

 <div class="messages"> hello my friend this is your link  https://strackoverflow.com  see you later </div>

Now I want to select all the divs that have the messages class And check its string if it contains http and there is a space at the end of http Put that part of the link inside the a tag with target _blank

  • have you tried anything on your end first? – Bhushan Kawadkar Sep 14 '22 at 05:50
  • Please add a minimal reproducible example https://stackoverflow.com/help/minimal-reproducible-example – BehRouz Sep 14 '22 at 05:53
  • Hello, there! welcome to SO :) as others have pointed out, having a code snippet in your question will help us help you better. To help you get on the right track, you probably want to use a regex to find the URLs in your content. [This SO question should help you get started](https://stackoverflow.com/questions/6038061/regular-expression-to-find-urls-within-a-string) – Chirag Ravindra Sep 14 '22 at 06:45

0 Answers0