[EDIT]
If you would like optionally to get first occurance of 99,00...
For lines:
My super data plan 10gb mobile 99,00 1 jul - 31 jul 2020 99,00
My super data plan 10gb mobile 1 jul - 31 jul 2020 99,00
Try this:
^(?<text>[\w\s]+)(?<num1>[\d]{2,},[\d]{2}){0,}\s(?<fromdate>\d{1,}\s\w{3})\s-\s(?<todate>\d{1,}\s\w{3})\s(?<year>\d{4})\s(?<num2>\d{2,},\d{2})$
Example - version 5[
^]
Matches:
1.
Group `text` 0-31 My super data plan 10gb mobile
Group `num1` 31-36 99,00
Group `fromdate` 37-42 1 jul
Group `todate` 45-51 31 jul
Group `year` 52-56 2020
Group `num2` 57-62 99,00
2.
Group `text` 63-93 My super data plan 10gb mobile
Group `fromdate` 94-99 1 jul
Group `todate` 102-108 31 jul
Group `year` 109-113 2020
Group `num2` 114-119 99,00
As you can see, in both cases group
text
is fetched correctly (to the first occurance of
99,99
-
num1
or to the first occurance of
1 jul
-
fromdate
).
num1
is fetched only if exists!
{0,}
- is used to define the number of occurencies for this group.
Good luck!