I want to look through a list of words and find any that match the pattern of ABCCDAA. How can I do this? Th开发者_如何学Pythonat is, find any words of length 7 whose letters correspond to that pattern (first and last two letters are X, etc).
regex is simple enough -
/^([a-zA-Z])([a-zA-Z])([a-zA-Z])\3([a-zA-Z])\1\1$/
Here's my solution:
([a-zA-Z]).([a-zA-Z])\2.\1\1
精彩评论