【发布时间】:2015-01-05 17:38:57
【问题描述】:
我想在一个单词中找到一个字符串,然后用 perl 中的另一个字符串替换整个单词。
例如:我有以下字符串。
my $str =
<schedule environment="sit">
<hours>SIT_HR</hours>
</schedule>
<schedule environment="uat">
<hours>UAT_HR</hours>
</schedule>
<schedule environment="prd">
<hours>PRD_HR</hours>
</schedule>
我必须找到 *_HR 并将其替换为 60。
输出:
<schedule environment="sit">
<hours>60</hours>
</schedule>
<schedule environment="uat">
<hours>60</hours>
</schedule>
<schedule environment="prd">
<hours>60</hours>
</schedule>
【问题讨论】:
-
添加到问题中您到目前为止尝试了什么。
-
由于我是 perl 新手,我只是想浏览如何在匹配时在字符串中找到 substr