Skip to content

Instantly share code, notes, and snippets.

@kazuho
Created October 2, 2014 02:41
Show Gist options
  • Save kazuho/1d09fdbedde0c0d8891e to your computer and use it in GitHub Desktop.
Save kazuho/1d09fdbedde0c0d8891e to your computer and use it in GitHub Desktop.
use strict;
use warnings;
my $re_paren;
$re_paren = qr {
\(
(?:
(?>[^\(\)]+)
| (??{ $re_paren })
)*
\)
}xs;
my $re_str = qr{"(?:\\"|[^"]*)*"};
my $src = join '', <STDIN>;
$src =~ s{
(?:(?<=[^A-Za-z0-9_])|^)
sprintf \s*
\( \s*
" ( (?:\\"|[^"]*)* ) "
(?: \s* , \s* ($re_paren|[^,]*) )*
\)
}{ print "yeah!:$1,$2,$3" }gxs;
print $src;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment