Skip to content

Instantly share code, notes, and snippets.

@juliangamble
Created September 8, 2011 04:29
Show Gist options
  • Save juliangamble/1202615 to your computer and use it in GitHub Desktop.
Save juliangamble/1202615 to your computer and use it in GitHub Desktop.
Regex comparison
#!/usr/bin/env perl
use strict;
use warnings;
#my $text = "\t \t";
#my $text = "\t\t \t";
#my $text = "\t\t \t\t \t";
my $text = "\t\t \t\t \t";
my $text2 = $text;
$text2 =~ s{(.*?)\t}{$1.(' ' x (4 - length($1) % 4))}ge;
print length($text2);
$text2 =~ $text;
$text2 =~ s/(.*?)\t/' '/;
print length($text2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment