我有一个文本,如何将其中的所有数字替换为更高的数字?
我试过如下:
$buffer_content=~s/(\d)/($1++)/g;
最佳答案
使用 s///e
- 评估修饰符,您可以在第二部分中放置任意 perl 代码。
$x = "hello 3";
$x =~ s/([0-9]+)/$1 + 1/eg;
print $x;
// hello 4
引用:http://perldoc.perl.org/perlretut.html#Search-and-replace
关于regex - Perl 正则表达式用自己替换数字,只是高一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13085561/