I want to write a regular expression to do the following.
The first character can be any character.
The second character can be anything except the first character.
The third character can be anything except the first two characters.
(This is a problem. There may be other problems.)
The fourth character is the same as the second character.
st = “abcb”
p st =~ /^(.)([^\1])([^\1\2])(\2)$/ # I expected a match
uv = “abbb”
p uv =~ /^(.)([^\1])([^\1\2])(\2)$/ # I did not expect a match
They both match.
How can I write the regular expression?
Somehow I have the syntax wrong.