I have a regular expression that involves some grouping, and I am having a difficult time understanding why the last character is being grouped alone using this regex:
Regex: ([A-Za-z]+).*([A-Za-z]+)
String Example: Hello World
I dont get why the 'd' is grouped alone by itself, I know it has something to do with .*
but cannot wrap my head around this when testing on https://www.regex101.com
If I put the .*
in the front of the expression only the l and the d are captured, why is that?
Any help appreciated, thanks