I have the following string:
"Group: I_am_group |SubGroup: I_am_subgroup"
And the following regex:
Group:\s(?<group>\w+) \|SubGroup:\s(?<subGroup>\w*)
The result is:
Until here- it's perfect to me, but when I am having the following case:
for the following strings:
1. "Group: I_am_group |SubGroup:"
2. "Group: I_am_group |"
3. "Group: I_am_group"
I want to get the result (e.g. for the string "Group: I_am_group"):
Match1 Group: I_am_group
group I_am_group
subGroup null
Is it possible with regex to create an empty group when it's not found? or give a default value to a group if the value not found?
In this case, I want to create the group named- 'subGroup' on the result with the value- null.