/ Published in: Perl
Text filter to increment numbers by one with regex in BBEdit (Mac only)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/perl -w # 1. Copy this to a new file in BBEdit (bottom bar of the file window) # 2. Choose Unix (LF) for line endings # 3. Save it to ~/Library/Application Support/BBEdit/Text Filters/ # 4. Relaunch BBEdit # 5. Invoke the script in "Text > apply text filter >" menu # 6. Presto! while(<>) { my $line = $_; # If you wish, you can personalize you regex by change the patterns... # ...between "s/" and "/ge" in the next line. # The slash in the middle divides the search and replace patterns. # The "e" part executes the replace as Perl code... # ...incrementing the value of the former number by one. $line =~ s/(\d+)/($1 + 1)/ge; }
URL: http://www.pagelab.com.br