20
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

正規表現: 日本人っぽい名前のローマ字にマッチする

Last updated at Posted at 2014-10-14

せっかく作ったのでメモ。

日本人っぽい苗字や名前、地名のローマ字表記にだいたいマッチする。Sublime Textの正規表現で確認しただけだけど、特別なことはしていないので他でもだいたい動くと思う。

^([AEIOUKSTNHMYRWGZDBCFJ][tshy]?[aeiou]?)([kstnhmyrwgzdbcfj]?[tshy]?[aeiou]n?)+$

RubyやPerl、PHPなどでは脆弱性対策のため以下を使用したほうがいい。

\A([AEIOUKSTNHMYRWGZDBCFJ][tshy]?[aeiou]?)([kstnhmyrwgzdbcfj]?[tshy]?[aeiou]n?)+\z
テストパターン
Tsushima
Yagi
Chikamatsu
Yokoyama
Masamichi
Tanakadate
Aikitsu
Terada
Torahiko
Natsume
Soseki
Lois
Armstrong
Bill
Evans
Oscar
Peterson
Buddy
Rich
Luis
Bellson
20
20
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?