Created
February 21, 2011 07:18
-
-
Save mrorii/836767 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/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