Last active
December 12, 2015 09:08
-
-
Save tokubass/4748842 to your computer and use it in GitHub Desktop.
twitterで見かけたつぶやきに対して。
先頭大文字、全部大文字、全部小文字の3パターンだけに仕様縮小。
もっと短く書きたいなぁ。
ver3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Test::More; | |
my $str = 'foo Foo FOO'; | |
$str =~ s{(foo)}{ my $len = scalar split(/[A-Z]/,$1); ( $len == 0 ) ? 'BAR' : ( $len == 1 ) ? 'bar' : 'Bar' }ieg; | |
is($str, 'bar Bar BAR'); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment