不包含特定字符串的匹配
2015-12-31 12:33
369 查看
正则表达式匹配不包含特定字符串的文本,相信很多初学者都会范难(特指本人)。
下面找到一个匹配:
其中 string 是要排除的字符串。
文本如下:
配置所有不包含 "all"的行,匹配结果如下:
除了红色下划线标注的行都匹配到了
参考文章:
http://www.vaikan.com/regular-expression-to-match-string-not-containing-a-word/
下面找到一个匹配:
^((?!string).)*$
其中 string 是要排除的字符串。
文本如下:
# particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it # below. # # all# DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. #(呵呵, 偷了个懒,随手截了httpd.conf的内容)
配置所有不包含 "all"的行,匹配结果如下:
除了红色下划线标注的行都匹配到了
参考文章:
http://www.vaikan.com/regular-expression-to-match-string-not-containing-a-word/
相关文章推荐
- Yii1.1 CHttpSession 的session属性配置项
- webstorm less Filewatcher
- dotNET跨平台研究的相关文档
- 猿题库 iOS 客户端架构设计
- jQuery+ajax实现文章点赞功能的方法
- C# 读取机器码,CPU序列号,生成注册码类(优化)
- NSDictionary、NSMutableDictionary的基本用法
- 三层架构——三层登录代码分析
- ASP.NET-FineUI开发实践-17
- java好书下载
- 超简单的UITableView下拉放大的动画
- vim快捷键2
- 【C#】利用C#窗体与SQL Server的连接、Treeview制作SQL Server数据库查看器
- Countly 案例研究:通过 60 亿月度数据点为《好照片》提供深入分析
- Android中的录音与音频合成
- 论信仰与精神需求--cuiz
- nyoj465 最大值和最小值
- iOS开发之UITableviewCell实现两个圆角
- 3-表约束修改
- ulimit详解