第七章 正则模式
来源:互联网 发布:苹果应用无法连接网络 编辑:程序博客网 时间:2024/06/05 21:02
模式分组:在数学中,圆括号() 用来分组。因此,圆括号也是元字符模式/fred+/ 会匹配像fredddddd这样的字符窜/(fred)+/ 会匹配像fredfredfred这种字符窜[root@jhoa 2015]# cat a8.pl $_="abba";if (/(.)\1/){ ##匹配bb print "It matched same character next to itself!\n"; print "\$1 is $1\n";}[root@jhoa 2015]# perl a8.pl It matched same character next to itself!$1 is b(.)\1 表明需要匹配连续出现的两个同样的字符反向引用不必总是附在相应的括号后面,下面的模式会匹配y后面的4个连续的非回车字符,并且用\1在d字符之后重复这个4个字符[root@jhoa 2015]# cat a9.pl $_ = "yabba dabba doo";if (/y(....) d\1/) { print "It matched the same after y and d !\n"; print "\$1 is $1\n";}[root@jhoa 2015]# perl a9.pl It matched the same after y and d !$1 is abba[root@jhoa 2015]# cat a11.pl $_ = "yabba dabba doo";if (/y(.)(.)\2\1/) { print "It matched the same after y and d !\n"; print "\$1 is $1\n"; print "\$2 is $2\n";}[root@jhoa 2015]# perl a11.pl It matched the same after y and d !$1 is a$2 is b匹配的是abba$_ = "yabba dabba doo";if (/y((.)(.)\3\2) d\1/) { print "It matched the same after y and d !\n"; print "\$1 is $1\n"; print "\$2 is $2\n";}~ ~ (/y((.)(.)\3\2) d\1/) ~ [root@jhoa 2015]# cat a10.pl $_ = "yabba dabba doo";if (/y((.)(.)\3\2) d\1/) { print "It matched the same after y and d !\n"; print "\$1 is $1\n"; print "\$2 is $2\n"; print "\$3 is $3\n";}[root@jhoa 2015]# perl a10.pl It matched the same after y and d !$1 is abba$2 is a$3 is b匹配abbd dabbd d
0 0
- 第七章 正则模式
- 第七章 正则表达式
- jquery 第七章 正则
- 第七章 正则表达式 笔记
- 第七章 正则表达式编程
- 第七章 代理模式
- 第七章 代理模式
- 第七章、grep及正则表达式
- php笔记----第七章 正则表达式
- 第七章 适配器模式&&外观模式
- js 设计模式 第七章 factory
- 第七章 MVC模式与视图间传值
- 第七章:datapump模式的搭建
- linux shell编程指南第七章------正则表达式介绍
- Dive into python第七章正则表达式学习笔记
- Perl语言入门笔记 第七章 漫游正则表达式王国
- 大话设计模式java版本 第七章 代理模式
- 第七课 策略模式
- iOS所有常用证书,appID,Provisioning Profiles配置说明及制作图文教程
- 取石子游戏
- Xcode把应用程序打包成ipa
- Linux 邮件发送mail
- Maven常用命令及示例
- 第七章 正则模式
- 网络基本功(十四):细说诊断工具ping
- 只有.mdf和ldf文件如何导入数据库?
- boost -- program_options 学习笔记
- 使用 Wiser 进行mail 单体测试
- 类图及类图中的关系
- 整理一些前端学习中好的书籍
- appstore中关于idfa的选项都是什么意思
- 网络基本功(十五):细说网络性能监测与实例(上)