I'm trying to create a regex that matches consecutive instances of an expression, but only if the text begins with that expression.
Let's say I want to find a number followed by a word: \d \w+
.
For the text:
1 word 2 letters some more words 3 groups
I want to get two groups: "1 word" and "2 letters", because the line starts with a match (a number and a word - "1 word"), and another one follows right after ("2 letters"). But I don't want it to match "3 groups".
For the text:
abc 1 word 3 letters
no groups should match because it starts with "abc".
Thanks in advance!