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

标签 javascript regex url-rewriting url-routing

如何创建不包含字符串“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/

相关文章:

javascript - Uncaught ReferenceError : Parse is not defined

javascript - 使用 AJAX 查询进行按键按下与更改时比较 : which is better?

javascript - 删除按键上的标签消息

c# - 用于识别网址的正则表达式

c# - 使用 c# for framework 4.0 在 asp.net webform 中进行 URL 路由/重写

apache - 在使用 mod_rewrite 的 Apache .htaccess 文件中,是否可以为域强制 www 和强制 https?

javascript - navigator.clipboard.writeText() 不适用于特定的 IOS 设备

javascript - Android Chrome 在旋转屏幕后使用 javascript 退出全屏后隐藏地址栏(错误?)

mysql - 是否需要修改 RegEx 模式才能与 MySql 中的 SQL 一起使用?

c# - 正则表达式公式 - 无法识别公式