Last active
August 15, 2022 09:58
-
-
Save kobaatsu/b3a7d8c64cfe454ba9bd36f03f90fe42 to your computer and use it in GitHub Desktop.
正規表現 #js #note
This file contains 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
// https://regex101.com/r/gXDhi9/1 | |
isValidImageUrl = (url) => { | |
const imgReg = | |
/^(?:(?<scheme>[^:/?#]+):)?(?:\/\/(?<authority>[^/?#]*))?(?<path>[^?#]*\/)?(?<file>[^?#]*\.(?<extension>[Jj][Pp][Ee]?[Gg]|[Pp][Nn][Gg]|[Gg][Ii][Ff]|[Ss][Vv][Gg]|[Ww][Ee][Bb][Pp]))(?:\?(?<query>[^#]*))?(?:#(?<fragment>.*))?$/gm; | |
return imgReg.test(url); | |
}; |
This file contains 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
/https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+/; |
This file contains 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
/https:\/\/(www\.)?(youtube\.com\/watch\?v=|youtu\.be\/)+[\S]{11}/; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment