当前位置 : 主页 > 编程语言 > c语言 >

perl中while修饰符/c参数

来源:互联网 收集:自由互联 发布时间:2023-09-03
[oracle@localhost ~]$ cat tmpperl01 #!/usr/bin/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";
[oracle@localhost ~]$ cat tmpperl01 

 #!/usr/bin/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"; 

[oracle@localhost ~]$ cat tmpperl02
 #!/usr/bin/perl
 $_ = "The year 1752 lost 10 days on the 3rd of September";
 while (/(\d+)/cg)
 {
 print pos($_),"\n";
 }
 print pos($_)."---","\n";
 while (/e/cg)
 {
 print pos($_),"\n";
 }
 print pos($_)."---","\n"; 
[oracle@localhost ~]$ ./tmpperl01
 13
 21
 35
---
 3
 6
 33
 43
 46
 49
---
 [oracle@localhost ~]$ ./tmpperl02
 13
 21
 35
35---
 43
 46
 49
49---#增加/c修饰符在匹配失败后不重置pos的位置
【本文转自:韩国cn2服务器 http://www.558idc.com/kt.html欢迎留下您的宝贵建议】
上一篇:集合的包含
下一篇:没有了
网友评论