Perl 单词边界
2014-12-04 19:14
169 查看
单词边界: \b匹配单词边界,就是位于单词(\w)和非单词字符(\W)之间的零宽度的地方。 就是单词前后必须跟非单词字符 [oracle@jhoa big]$ cat 11.pl #$var = "The Great Fred"; $var = "Fred erick the Great"; if ($var =~/\bFred\b/){print "$var\n"}; [oracle@jhoa big]$ perl 11.pl Fred erick the Great [oracle@jhoa big]$ cat 11.pl #$var = "The Great Fred"; $var = "aFred erick the Great"; if ($var =~/\bFred\b/){print "$var\n"}; [oracle@jhoa big]$ perl 11.pl [oracle@jhoa big]$ Fred前面出现单词字符 ,匹配不上 [oracle@jhoa big]$ cat 11.pl #$var = "The Great Fred"; $var = "Freda erick the Great"; if ($var =~/\bFred\b/){print "$var\n"}; [oracle@jhoa big]$ perl 11.pl [oracle@jhoa big]$ Fred后面出现单词字符匹配不上 [oracle@jhoa big]$ cat 11.pl #$var = "The Great Fred"; $var = "!Fred erick the Great"; if ($var =~/\bFred\b/){print "$var\n"}; [oracle@jhoa big]$ perl 11.pl !Fred erick the Great [oracle@jhoa big]$ 单词前面出现非单词字符,可以匹配 [oracle@jhoa big]$ cat 11.pl #$var = "The Great Fred"; $var = "Fred! erick the Great"; if ($var =~/\bFred\b/){print "$var\n"}; [oracle@jhoa big]$ perl 11.pl Fred! erick the Great [oracle@jhoa big]$ 单词后面出现非单词字符,可以匹配
相关文章推荐
- perl-单词边界匹配
- 正则表达式(单词边界 \b)
- 正则基础之--/b单词边界
- 【转】正则基础之——/b 单词边界
- perl计算单词出现次数
- 正则表达式知识详解之单词边界 (java版示例)
- Perl统计英文单词(没有考虑缩写和连写词)
- 正则基础之"/b"单词边界
- C#正则表达式之单词边界
- 正则基础之--/b 单词边界
- perl从网页分析出英文单词
- C#正则表达式-单词边界
- 正则基础之 \b 单词边界(http://www.jb51.net/article/19330.htm)
- 用Perl实现单词计数器
- 正则之\b单词边界
- shell和perl对文件单词的频数统计
- 正则表达式笔记 2 边界符中的单词边界 \b
- 正则入门:匹配单词边界
- 正则表达式单词边界和非单词边界
- vim中正则表达式匹配单词边界