如何在 Perl 中搜索某个单词后的任意数字
Changeset: 40042
User: xyz
Date: Friday, July 29, 2011 9:54:52 PM
评论:
[I#1326920] RINS 参考数据维护开发已完成。添加了 RINDefinition、RINEquivalence 和 RINObligati
项目:
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/application/common/ICTSDatabaseObjectMaps.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/apps/admin/application/client/controller/MainController.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/apps/admin/control/common/AdminCache.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/apps/admin/control/common/AdminManager.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/_RINDefinition.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/_RINEquivalence.java
Changeset: 40043
User: xyzx
Date: Friday, July 29, 2011 9:54:52 PM
注释:
[I#1326920] RINS 参考数据维护开发已完成。添加了 RINDefinition、RINEquivalence 和 RINObligati
项目:
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/_RINObligation.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/Commodity.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/CommodityType.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/RINDefinition.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/RINEquivalence.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/RINObligation.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINDefinitionMap.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINDefinitionMap.xml
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINEquivalenceMap.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINEquivalenceMap.xml
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINObligationMap.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINObligationMap.xml
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/trade/TradeLocalizedResources.java
签入 注意:
Code Reviewer:
Performance Reviewer:
Security Reviewer:
以上行位于一个数组中。我想逐行阅读它,如果任何行包含 Changeset:
则获取 Changeset 旁边的数字: 请建议我如何做到这一点。
提前致谢。
来自OP评论的代码:
foreach(@loginfo){
#print "$_\n";
@rev = $_=~/^C(\d{1,})/g;
#print "....@rev\n";
push(@rev_value,@rev);
print @rev_value,"\n";
}
Changeset: 40042
User: xyz
Date: Friday, July 29, 2011 9:54:52 PM
Comment:
[I#1326920] RINS Reference Data Maintenance Development completed. Added RINDefinition,RINEquivalence and RINObligati
Items:
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/application/common/ICTSDatabaseObjectMaps.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/apps/admin/application/client/controller/MainController.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/apps/admin/control/common/AdminCache.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/apps/admin/control/common/AdminManager.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/_RINDefinition.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/_RINEquivalence.java
Changeset: 40043
User: xyzx
Date: Friday, July 29, 2011 9:54:52 PM
Comment:
[I#1326920] RINS Reference Data Maintenance Development completed. Added RINDefinition,RINEquivalence and RINObligati
Items:
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/_RINObligation.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/Commodity.java
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/CommodityType.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/RINDefinition.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/RINEquivalence.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/RINObligation.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINDefinitionMap.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINDefinitionMap.xml
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINEquivalenceMap.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINEquivalenceMap.xml
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINObligationMap.java
add $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/commoditymarket/maps/RINObligationMap.xml
edit $/S/B/F_RINS/Java/V3/ICTS/src/com/tradecapture/icts/model/trade/TradeLocalizedResources.java
Check-in Notes:
Code Reviewer:
Performance Reviewer:
Security Reviewer:
The above lines are in one array. I want to read it line by line and if any line contains Changeset:
then get the number next to Changeset:
Please suggest me how to do this.
Thanks in advance.
Code from OP's comment:
foreach(@loginfo){
#print "$_\n";
@rev = $_=~/^C(\d{1,})/g;
#print "....@rev\n";
push(@rev_value,@rev);
print @rev_value,"\n";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需使用 regexp - man perlre
编辑:
输出
just use regexp - man perlre
EDIT:
outputs
如果数组中包含所有行,则可以使用
map
如果您用文件句柄替换数组,例如
<$fh>
(或任何列表),也可以工作。If you have all the lines in an array, you can use
map
Also works if you replace the array with a filehandle, e.g.
<$fh>
(or any list, for that matter).