Created
November 6, 2018 18:25
-
-
Save gadzhimari/88733d354e670781259f3b4e9fe0fb23 to your computer and use it in GitHub Desktop.
Detect url in text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const pattern = /(?:\[(.+)\]\()?((?:https?|ftp):\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=():!,\'\'\*]*))/ig; | |
// const pattern = /(?:\[(.+)\]\()?((https?:\/\/|ftps?:\/\/)?([a-z0-9\-]+\.){1,}([a-z0-9\-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:\/\?#\[\]@!$&'\(\)\*\+,;=%]+)?)?)/ig; | |
const pattern = /(?:\[(.+)\]\()?(((?:https?|ftps?):\/\/)?(?:www\.)?[-a-z0-9]+\.[a-z]{2,6}\b([-a-z0-9._~:\/\?#\[\]@!$&'()\*\+,;=%]+)?)/ig; | |
// | |
// const pattern = /(?:\[(.+)\]\()?((?:https?|ftp):\/\/\S+)/ig; | |
// const pattern = /(?:\[(.+)\]\()?(([--:\w?@%&+~#=]*\.[a-z]{2,4}\/{0,2})((?:[?&](?:\w+)=(?:\w+))+|[--:\w?@%&+~#=\(\)]+)?)/ig; | |
// const pattern = /(?:\[(.+)\]\()?((?:https?(?::\/\/))?(?:www\.)?(?:[a-zA-Z\d-_.]+(?:\.[a-zA-Z\d]{2,}))(?:(?:[-a-zA-Z\d:%_+.~#!?&//=@]*)(?:[,](?![\s]))*)*)/ig; | |
// const pattern = /(?:\[(.+)\]\()?(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}(\.[a-z]{2,6}|:[0-9]{3,4})\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/ig; | |
// | |
// const pattern = /(?:\[(.+)\]\()?((https?:\/\/|ftps?:\/\/)?([a-z0-9\-]+\.){1,}([a-z0-9\-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:\/\?#\[\]@!$&'\(\)\*\+,;=%]+)?)?)/ig; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment