Very simple direct question, I need a regex for pattern in a Input wich only accepts vowells and numbers => It must contain both
CodePudding user response:
If a string has both a vowel and a digit, either:
- the digit is in front of the vowel (ie digit random stuff vowel)
- The digit is behind the vowel (ie vowel random stuff digit)
Hence the following regex should work:
let regex = /[aeiouAEIOU].*[0-9]|[0-9].*[aeoiuAEIOU]/
Test cases:
CodePudding user response:
Here is the regex, it's not the best but it works:
If you want documentation about regex: