uribo / zipangu

Japanese utility functions and data
https://uribo.github.io/zipangu
Other
56 stars 7 forks source link

Improve is_jyear() character matching #30

Closed uribo closed 3 years ago

uribo commented 3 years ago

Summary

元号の漢字表記とローマ字表記とのマッチ、元号の頭文字のマッチを分割。頭文字の場合、年を表す数値が連続して与えられていない場合には FALSE を返却するように。

library(zipangu)
zipangu:::is_jyear(c("令和元年", "Reiwa2", 
                     # 存在しない元号
                     "reima3"))
#> [1]  TRUE  TRUE FALSE
convert_jyear("Reima3")
#> Warning: Unsupported Japanese imperial year.
#> Please include the year after 1868 or the year used since then, Meiji, Taisho, Showa, Heisei and Reiwa.
#> [1] NA
convert_jyear("平30")
#> [1] 2018
convert_jyear("平ら")
#> Warning: Unsupported Japanese imperial year.
#> Please include the year after 1868 or the year used since then, Meiji, Taisho, Showa, Heisei and Reiwa.
#> [1] NA

Created on 2021-02-01 by the reprex package (v1.0.0)

Related issues

Close #22