I have been using this regex to validate YouTube links using JavaScript:
function is_valid_video(url) {
var p = /^(?:http?:\/\/)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
return (url.match(p)) ? RegExp.$1 : false;
}
Since I'm learning to develop Android apps, I want to convert this function to use it in Java.
public static bool is_valid_video(String url) {
return url.matches("Your Regex Goes Here");
}
Read this article for more help.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments