I am learning how to use regular expressions to validate user inputs. I am using jQuery for this. I just want to know if the OR operator can be used inside an expression.
I want to check if there is a line:
- One letter first and then at least 6 digits
OR
- At least 6 digits first, then one letter
Examples:
X123456... OR 123456P
I use this /^[a-zA-Z]\d{6}/ for the first, but can I use something like this to take into account both conditions?
/^[a-zA-Z]\d{6}/ | /^\d{6}/[a-zA-Z] ??
thanks for the help
source share