To exclude all URLs that contain mysubstring1
, I simply typed mysubstring1
(the pattern) in the field of the special service, and it works.
However, I need to modify this pattern, as I need to make an exclusion: URLs that contain mysubstring1/mysubstring2
should be allowed.
What should be the pattern instead of mysubstring1
in this case?
As that service states, you should provide just the regex pattern you want to match.
https://www.example.com/good/ //Matches, as contains no "mysubstring1"
https://www.example.com/mysubstring1/ //No match
https://www.example.com/mysubstring1/ //No match
https://www.example.com/mysubstring1/morning/ //No match
https://www.example.com/mysubstring1/mysubstring2/iugnyug //Matches, as contains "mysubstring1/mysubstring2"
https://www.example.com/mysubstring1/evening/ //No match
https://www.example.com/mysubstring1/night/ //No match
Here is some more information provided:
https://experienceleague.adobe.com/docs/data-workbench/using/dataset/c-reg-exp.html?lang=en
Per example from there
text1|text2
Alternative: text1 or text2
however, for my case it should not be OR |
, but rather NOT
.
CodePudding user response:
Try wrapping it with ^
and $
.
Example:
/^mysubstring1$/g
CodePudding user response:
^(?=.*(?:mysubstring1))(?!.*(?:mysubstring2)).*$
seems to be an answer.