regex return conditional group
- by priyank.mp
Hi ,
I spent lot time figuring out a simple regex to return a group (only 1st group).
So the string can be -
"No purchase required" or "Purchase of $50.00 worth groceries is required."
I am trying to write a regex which can parse "No" or "50" based on the given string.
This is what I have written.
(?:(No) monthly maintenance|Purchase of \$([\d\.]+ worth groceries)
This works fine but I want my output as 1st group/group 1 only.