Return to Snippet

Revision: 57214
at May 22, 2012 08:50 by page_lab


Updated Code
#!/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;
	print $line;
}

Revision: 57213
at May 22, 2012 08:49 by page_lab


Initial Code
#!/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;
	print $line;
}

Initial URL
http://www.pagelab.com.br

Initial Description
Text filter to increment numbers by one with regex in BBEdit (Mac only)

Initial Title
BBEdit text filter - increment value by one

Initial Tags
regex, mac, perl

Initial Language
Perl