Skip to content

Instantly share code, notes, and snippets.

@mwgamera
Last active December 3, 2017 23:23
Show Gist options
  • Save mwgamera/854fded72f648f65098fbf2daff4b2de to your computer and use it in GitHub Desktop.
Save mwgamera/854fded72f648f65098fbf2daff4b2de to your computer and use it in GitHub Desktop.
use utf8;
use Unicode::Normalize;
# Expand horizontal Kana iteration marks
# 例: いすゞ→いすず ところゞゝゝ→ところどころ
sub expand_kanaiter {
local $_ = NFKD($_[0]);
s{(
[あ-んア-ンー][\x{3099}\x{309a}]?
(|(?1))
[ゝヽ][\x{3099}\x{309a}]?
)}{
local $_ = $1;
pos = $-[3]
while s/
\G([あ-んア-ンー])
([\x{3099}\x{309a}]?)
([^ゝヽ]*)[ゝヽ]
([\x{3099}\x{309a}]?)
/$1$2$3$1$4/x;
$_
}xge;
NFC($_);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment