I'm sure I'm missing something obvious, but I'm trying to match multiple capture groups, requiring one of each and can't see what's wrong. This is regex for Golang.
Given:
abc.com
abc.com/help
abc.com/win
abc.com/lose
abc.com/lose/wowyoulost
www.abc.com/win
www.abc.com/really/you/win
cde.com
cde.com/win
And the regex:
(abc\.com)+(win|lose)+
I am trying to require 1 or more of the first group and 1 or more of the second group. The intended outcome should be:
abc.com - NO MATCH
abc.com/help - NO MATCH
abc.com/win - MATCH
abc.com/lose - MATCH
abc.com/lose/wowyoulost - MATCH
www.abc.com/win - MATCH
www.abc.com/really/you/win - MATCH
cde.com - NO MATCH
cde.com/win - NO MATCH
What am I doing wrong?
^abc\.com/(win|lose)? See regex101.com/r/Gjpkl7/1. Note that your regex could not match the strings because there is no/in the pattern to match the/in the strings.^(?:www\.)?abc\.com(?:/[^/]+)*/[^/]*(?:win|los[te])demo (where all[^/]are replaced with[^/\n]since it is a single multiline string demo)