gpt4 book ai didi

javascript - 正则表达式 - 不包含字符串且不以/结尾

转载 作者:行者123 更新时间:2023-11-30 10:20:18 24 4
gpt4 key购买 nike

如何创建不包含字符串“umbraco”且不以/结尾的正则表达式

这是我目前所拥有的,但我无法使其完全正常工作,我们将不胜感激。

(?!umbraco)(?![/]$)

测试字符串是:

最佳答案

应该是这个正则表达式:

^(?!.*?umbraco).*?[^\/]$

在线演示:http://regex101.com/r/lM0cS9

解释:

^ assert position at start of a line
(?!.*?umbraco) Negative Lookahead - Assert that it is impossible to match the regex below
.*? matches any character (except newline)
Quantifier: Between zero and unlimited times, as few times as possible, expanding as needed
umbraco matches the characters umbraco literally (case sensitive)
.*? matches any character (except newline)
Quantifier: Between zero and unlimited times, as few times as possible, expanding as needed
[^\/] match a single character not present in the list below
\/ matches the character / literally
$ assert position at end of a line

关于javascript - 正则表达式 - 不包含字符串且不以/结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21751507/

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