Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Last active June 16, 2019 06:01
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 xtetsuji/bfbc360e0c5c714c8754b35b5b5504e0 to your computer and use it in GitHub Desktop.
Save xtetsuji/bfbc360e0c5c714c8754b35b5b5504e0 to your computer and use it in GitHub Desktop.
match regular expression of 1..99 kanji numerals
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
# 漢数字 1..9 の一文字 (need: use utf8)
my $kd_re = qr/[一二三四五六七八九]/;
# 1..99 の漢数字表現
my $kanji_numerals_re = qr{
$kd_re # 一桁
|
$kd_re? (?<!一)十 $kd_re? # 二桁で「十」を伴う場合
|
$kd_re (?:$kd_re|〇) # 二桁で「十」を伴わない場合
}x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment