正则表达式字符串不包含子字符串 [英] regex string does not contain substring

查看:59
本文介绍了正则表达式字符串不包含子字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试匹配不包含子字符串的字符串

I am trying to match a string which does not contain a substring

我的字符串总是以http://www.domain.com/"开头

My string always starts "http://www.domain.com/"

我想从匹配中排除的子字符串是.a/",它跟在字符串之后(域名中的文件夹名称)

The substring I want to exclude from matches is ".a/" which comes after the string (a folder name in the domain name)

我想排除的子串后面的字符串会有字符

There will be characters in the string after the substring I want to exclude

例如:

不应匹配http://www.domain.com/.a/test.jpg"

"http://www.domain.com/.a/test.jpg" should not be matched

但是http://www.domain.com/test.jpg"应该是

But "http://www.domain.com/test.jpg" should be

推荐答案

使用否定前瞻断言:

^http://www\.domain\.com/(?!\.a/).*$

Rubular 链接

部分 (?!\.a/) 匹配除 .a/

这篇关于正则表达式字符串不包含子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆