You can't get overlapping matches in Regex. You have several ways to work around it, though. You can either use Regex.Match
, and specify a starting index (use a loop to go through your whole string), or you can use lookbehinds or lookaheads, like so:
(?=[^aeiou]a)[^aeiou]
This works because lookbehinds and lookaheads do not consume the characters. It returns a Match
which contains the index of the match. You'd need to use that instead of captures, since only one character is captured.