正则表达式:匹配除特定模式之外的所有内容 [英] Regex: match everything but specific pattern

查看:47
本文介绍了正则表达式:匹配除特定模式之外的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个能够匹配所有内容的正则表达式以特定模式开头的字符串(特别是 index.php 以及后面的内容,例如 index.php?id=2342343)

I need a regex able to match everything but a string starting with a specific pattern (specifically index.php and what follows, like index.php?id=2342343)

推荐答案

不是正则表达式专家,但我认为您可以从一开始就使用否定前瞻,例如^(?!foo).*$ 不应匹配任何以 foo 开头的内容.

Not a regexp expert, but I think you could use a negative lookahead from the start, e.g. ^(?!foo).*$ shouldn't match anything starting with foo.

这篇关于正则表达式:匹配除特定模式之外的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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