Question:
Is is possible, with regex, to match a word that contains the same character in different positions?
Condition:
All words have the same length, you know the character positions (example the 1st, the 2nd and the 4th) of the repeated char, but you don't know what is it.
Examples:
using lowercase 6char words I'd like to match words where the 3rd and the 4th chars are the same.
parrot <- match for double r
follia <- match for double l
carrot <- match for double r
mattia <- match for double t
rettoo <- match for double t
melone <- doesn't match
I can't use the quantifier [d]{2} because it match any succession of two chars, and what if I say the 2nd and the 4th position instead of 3rd and 4th?
Is it possible to do what I want with regex? If yes, how can I do that?
EDIT:
Ask asked in the comments, I'm using python
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…