I'm currently using this RegEx to match every link in a string:
let regex = /\b(https?:\/\/)?(([a-z\d]+([-_][a-z\d]+)*)\.)+\w{2,32}(:[\d]{2,5})?([-a-z0-9@:%_+.~#?&/=]*)\b/gi;
These links match without any problem, and this is intended.
https://gle.co.ulk.co.com:443/?key=test&5345@%20#arr/do
https://google.coshe
google.comls
google.co
These links will match too, but the last /
(trailing slash) is not included in the matches, which is not intended:
https://gle.co.ulk.co.com:443/?key=test&5345@%20#arr/do/
https://google.coshe/
google.comls/
google.co/
I've tried using these match groups instead of ([-a-zA-Z0-9@:%_+.~#?&/=]*)
, without any success:
([-a-zA-Z0-9@:%_+.~#?&/=]*)\/?
([-a-zA-Z0-9@:%_+.~#?&/=]*\/?)
(([-a-zA-Z0-9@:%_+.~#?&/=]\/?)*)