Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1182574
  • 博文数量: 398
  • 博客积分: 10110
  • 博客等级: 上将
  • 技术积分: 4055
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-23 20:01
个人简介

新博客http://www.cnblogs.com/zhjh256 欢迎访问

文章分类

全部博文(398)

文章存档

2012年(1)

2011年(41)

2010年(16)

2009年(98)

2008年(142)

2007年(100)

我的朋友

分类:

2009-04-19 13:34:47

## 增加/c修饰符在匹配失败后不重置pos的位置,例如
C:\Documents and Settings\Administrator>perl
$_ = "The year 1752 lost 10 days on the 3rd of September";
while (/(\d+)/g)
{
    print pos($_),"\n";
}
print pos($_),"\n";
while (/e/g)
{
  print pos($_),"\n";
}
print pos($_),"\n";
^D
13
21
35
3
6
33
43
46
49

C:\Documents and Settings\Administrator>perl
$_ = "The year 1752 lost 10 days on the 3rd of September";
while (/(\d+)/gc)
{
    print pos($_),"\n";
}
print pos($_),"\n";
while (/e/gc)
{
  print pos($_),"\n";
}
print pos($_),"\n";
^D
13
21
35
35
43
46
49
49
阅读(652) | 评论(0) | 转发(0) |
0

上一篇:perl eval的作用

下一篇:正则表达式之a not b

给主人留下些什么吧!~~