EDIT: I recently found out(with help from some kind Stack Overflow users) that there are valid YouTube videos that are only letters.
Same question as here but with the addition of checking letters into the equation.
I was wondering if it is possible for the video ids for YouTube videos to be comprised of just numbers like this:
12345678901.
I'm writing an expression to validate a string that is a YouTube video id. Here is a simplified version of the expression in action(source here for further debugging):
const foo = /((http?(?:s)?:?\/\/)?(www\.)?)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?&v=))((?:\w|-){11})((?:\&|\?)\S*)?|(?:^(\w|-){11}$)|(?:\w|-){11}$/;
let bar = "dQw4w9WgXcQ"
// logs true
console.log("is valid: " + foo.test(bar));
Is it possible to write a regular expression that matches a string that does not only contain numbers or letters?
Criteria
These should work:
- abcdefghijk
- ecK3EnyGD8o
- 1s3get2-3ds
- 4bc2qfs2wrf
- 28yq389gfwg
- 3oyh8pw489p
But these shouldn't:
abcdefghijk- 12345678910? (unknown at the moment if YouTube supports video ids that are only numbers)
- 18974107892351240891751928347819234
- Stack Overflow
- kjsad;kflj;klasdfkjalk;sdfjlkas
- !&$@#)&&()%&*(#@$&(