You can find aa[^a] , which will find your two a and nothing else.
EDIT: oh boy, y'all after an exact match :-) So, to match exactly two aa and nothing else:
[^a]\zsaa\ze[^a]\|^\zsaa\ze$\|^\zsaa\ze[^a]\|[^a]\zsaa\ze$
And branch extensions:
[^a]\zsaa\ze[^a] \|^\zsaa\ze$ \|^\zsaa\ze[^a] \|[^a]\zsaa\ze$
They cover all unforeseen situations - aa can be at the beginning, in the middle or at the end of any line. And there cannot be more than two a together.
\zs means the actual match begins.\ze means the actual match ends here.- the first branch finds
aa in a string surrounded by other characters - the second branch finds
aa when it makes up the whole line - the third branch finds
aa at the beginning of the line - and the fourth branch finds
aa at the end of the line.
My mind is afraid of such fantastic things as looks at appearance, so I tried to stick to reasonably simple concepts of regular expressions.
EDIT 2: see @benjifisher a simplified, more elegant version below for your intellectual pleasure.
Yawar source share