I have .Net Regex ([abc][e])+([abc]) but when I try to match, it matches only few characters and not the whole string in a group.
Here is my input and desired output groups
- aebeceaxyz – Group 1 (aebece), Group 2 (a)
- aebecebxyz – Group 1 (aebece), Group 2 (b)
- aebececxyz – Group 1 (aebece), Group 2 (c)
- beceaecxyz – Group 1 (beceae), Group 2 (c)
In my Regex, I am getting the result of (ce)(a)/(ce)(b)/(ce)(c)/(ae)(/c) which is not what I want.
You’re getting the first match of [abc][e] in the first group, but you want to wrap some parens around the entire group you’re capturing. Also, you can use ?: to make the inner group non-capturing. This should give the result you’re looking for: