For example, find all aa groups in aaa string. This should result in two aa matches, the first one starting at index 0 and the second starting at index 1.
>Solution :
You can use positive lookahead to crossmatch all aa strings in the given aaa string. The regex you are looking for is (?=(aa)).
JS Example
console.log(Array.from("aaa".matchAll(/(?=(aa))/g)).map(i => i[1]))
Python Example
import re
re.findall(r"(?=(aa))", "aaa") # ['aa', 'aa']