Skip to content

Instantly share code, notes, and snippets.

@fjyuu
Created May 5, 2012 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjyuu/2599346 to your computer and use it in GitHub Desktop.
Save fjyuu/2599346 to your computer and use it in GitHub Desktop.
分かち書きしないっぽい文字を表す正規表現(User-Defined Character Properties)
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.010;
binmode STDOUT, ":utf8";
my $text = "これはpenです";
$text =~ s/(\p{IsNonSpacingCharacter})([^\p{IsNonSpacingCharacter}])/$1 $2/g;
$text =~ s/([^\p{IsNonSpacingCharacter}])(\p{IsNonSpacingCharacter})/$1 $2/g;
say $text; # これは pen です
sub IsNonSpacingCharacter {
return <<'END';
+utf8::Hiragana
+utf8::Katakana
+utf8::InKatakana
+utf8::Han
+utf8::InCJKSymbolsAndPunctuation
+utf8::InHalfwidthAndFullwidthForms
END
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment