How to validate the below url's which is ending with extensions like .mp4 or .wmv
And also starting with http or https or www
Example:
http://media.ch9.ms/ch9/360b/74fd8811-951f-40aa-bc24-91d51b82360b/Search.mp4
https://media.ch9.ms/ch9/360b/74fd8811-951f-40aa-bc24-91d51b82360b/Search.mp4
www.media.ch9.ms/ch9/360b/74fd8811-951f-40aa-bc24-91d51b82360b/Search.mp4
More readable:
^(http:\/\/|https:\/\/|www\.).*(\.mp4|\.mkv)$
More concise:
^(http(s)?:\/\/|www\.).*(\.mp4|\.mkv)$
Demo:
Explanation:
/^(http[s]?:\/\/)?([^:\/\s]+)(:([^\/]*))?(\/\w+\.)*([^#?\s]+)(\?([^#]*))?(\.mp4|\.mkv)$/gm
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.