简体   繁体   English

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

[英]Regex - Not containing a string and not ending with a /

How do I create a regular expression which don't contain the string "umbraco" and doesn't end with a / 如何创建不包含字符串“ umbraco”且不以/结尾的正则表达式

This is the what I have so far but I'm unable to get it fully working, any help would be appreciated. 这是我到目前为止所拥有的,但是我无法使其完全正常工作,我们将不胜感激。

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

Test strings would be: 测试字符串为:

It should be this regex: 应该是这个正则表达式:

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

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

Explanation: 说明:

^ 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

This should be the regex 这应该是正则表达式

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

demo http://rubular.com/r/tEhY7JFjXK 演示http://rubular.com/r/tEhY7JFjXK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM