Skip to content

Instantly share code, notes, and snippets.

@mrorii
Created February 21, 2011 07:18
Show Gist options
  • Select an option

  • Save mrorii/836767 to your computer and use it in GitHub Desktop.

Select an option

Save mrorii/836767 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use utf8;
use Encode;
my $string = "株式会社DeNAは、株式会社グリーのほげほげfoobar
hoafooasdfkj株式会社Googleはほげあlksjd";
my @list = ($string =~ /株式会社.*?\p{hiragana}/g);
for my $word (@list) {
if (substr($word, -1, 1) =~ /\p{hiragana}/) {
$word = substr($word, 0, length($word) - 1);
}
print Encode::encode('utf8', $word), "\n";
}
# 実行結果
#----------------
# 株式会社DeNA
# 株式会社グリー
# 株式会社Google
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment