gpt4 book ai didi

regex - RegEx不包含字符串,但包含另一个字符串

转载 作者:行者123 更新时间:2023-12-03 16:39:38 25 4
gpt4 key购买 nike

寻找有关Google Analytics(分析)正则表达式的帮助,其中URL不能包含/g-c/,但确实包含_brochure_productsheet_casestudy

以下是我想出的内容,但在tester中不起作用。

^(?!.*/g-c/)_Brochure|_ProductSheet|_CaseStudy


示例网址将被计数:

/contentitems/techlibrary/documents/conveying-solutions/cs1-003_brochure
/contentitems/techlibrary/documents/6507_brochure
/contentitems/techlibrary/documents/pt5-001m-g_productsheet


示例URL将不计算在内(因为 /g-c在URL或宣传册之前未使用下划线):

/contentitems/techlibrary/documents/cs1-003brochure
/contentitems/techlibrary/documents/g-c/cs1-003_brochure
/contentitems/g-c/documents/conveying-solutions/cs5-009_productsheet

最佳答案

我想你要这个

^(?!.*\/g-c\/).*(_Brochure|_ProductSheet|_CaseStudy)+.*$


您的正则表达式正在做类似的事情
“我希望不匹配/ g-c /或不匹配_Brochure ...”

关于regex - RegEx不包含字符串,但包含另一个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51432203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com