Reputation: 543
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
Upvotes: 2
Views: 1562
Reputation: 7722
More readable:
^(http:\/\/|https:\/\/|www\.).*(\.mp4|\.mkv)$
More concise:
^(http(s)?:\/\/|www\.).*(\.mp4|\.mkv)$
Demo:
Explanation:
Upvotes: 3
Reputation: 8193
/^(http[s]?:\/\/)?([^:\/\s]+)(:([^\/]*))?(\/\w+\.)*([^#?\s]+)(\?([^#]*))?(\.mp4|\.mkv)$/gm
see demo here https://regex101.com/r/vL1gZ5/2
Upvotes: 2