I have following RegEx: (([a-zA-Z0-9?]{4,8})(-[a-zA-Z0-9?]{4,8})+-([a-zA-Z0-9?]{4,8}))
How can I avoid matching sequences which do not contain at least one digit AND one character (a-zA-Z)?
For example:
This text:
Hello World 123 abc 1AB2C-D3FGH-456I7-JK8LM-NOP9Q Hello World 123 abc
should return 1AB2C-D3FGH-456I7-JK8LM-NOP9Q
and this:
Hello World 123 abc 11111-1111-1111 Hello World 123 abc
or
Hello World 123 abc aaaa-aaaa-aaaa-aaa Hello World 123 abc
should return nothing.
I develop in Java and get the group like this:
public List<String> getKeys() {
keys = new ArrayList<>();
Matcher matcher = KEY_REGEX.matcher(text);
while (matcher.find()) {
keys.add(matcher.group());
}
return keys;
}
Thanks!