-1

I'm looking for a regex that can pick out two urls that have no separating character. I have a regex which correctly idtentifies urls in the way I would want it to but it fails if the urls are touching.

CURRENT REGEX

It's for a chat service, for instance in the message "Hey checkout these links www.google.comwww.apple.com", I want to be able to identify both links as two separate links.

I'm looking for a REGEX solution idealy, but I'm open to other solutions.

Cody E
  • 179
  • 11

1 Answers1

0

The only reasonable anchors I could identify are the protocol part and the www subdomain in conjunction with a tempered greedy token:

((https?:\/\/(www)?)|www\.)(?:(?!https?:\/\/|www\.).)+

Demo

wp78de
  • 18,207
  • 7
  • 43
  • 71