I'm trying to create a grepl regex in R to match strings that:
- Contain 1 or more lowercase letters
- Contain 1 or more numbers
- Only allow lowercase letters (a-z) or numbers, i.e. no spaces, no special characters, no other punctuation
- The string must be exactly 8 characters long
However, my attempt so far doesn't yield any luck:
grepl("((?=.*[[:lower:]])(?=.*[[:digit:]])[[:alpha:]]{8})", x, perl=TRUE)
Any ideas where I'm going wrong?
Examples of inclusion cases would be: xxxxxxx8, 1234567x, ab12ef78
Examples of exclusion cases would be: x!3d5f78, x23456789, Ab123456