BBEdit文本筛选器-按1递增值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BBEdit文本筛选器-按1递增值相关的知识,希望对你有一定的参考价值。

Text filter to increment numbers by one with regex in BBEdit (Mac only)
  1. #!/usr/bin/perl -w
  2.  
  3. # 1. Copy this to a new file in BBEdit (bottom bar of the file window)
  4. # 2. Choose Unix (LF) for line endings
  5. # 3. Save it to ~/Library/Application Support/BBEdit/Text Filters/
  6. # 4. Relaunch BBEdit
  7. # 5. Invoke the script in "Text > apply text filter >" menu
  8. # 6. Presto!
  9.  
  10. while(<>) {
  11. my $line = $_;
  12.  
  13. # If you wish, you can personalize you regex by change the patterns...
  14. # ...between "s/" and "/ge" in the next line.
  15. # The slash in the middle divides the search and replace patterns.
  16. # The "e" part executes the replace as Perl code...
  17. # ...incrementing the value of the former number by one.
  18.  
  19. $line =~ s/(d+)/($1 + 1)/ge;
  20. print $line;
  21. }

以上是关于BBEdit文本筛选器-按1递增值的主要内容,如果未能解决你的问题,请参考以下文章