This regex expression will match the specified number of word characters, with a space in either side:
(?<=\s)(?:\w){12}(?=\s)
How can I modify this expression so that it returns only the string containing the mixed-alphanumeric result containing at least one letter and at least one number? Here is the current
CodePudding user response:
Try:
\b(?=[^\s]*\d)(?=[^\s]*[a-zA-Z])\w{12}\b
\b
- word boundary
(?=[^\s]*\d)
- continue matching if ahead is a number preceded with any amount of non-space characters.
(?=[^\s]*[a-zA-Z])
- the same with letters
\w{12}
- match 12 word characters
\b
- word boundary