LoginSignup
918
743

More than 5 years have passed since last update.

なるべく短い正規表現で住所を「都道府県/市区町村/それ以降」に分けるエクストリームスポーツ

Last updated at Posted at 2016-01-26

住所から「都道府県/市区町村/それ以降」の3ヵ所をキャプチャする正規表現を作りたい。

サンプル(Ruby)
rex = /ごにょごにょ/

p "東京都文京区後楽1丁目3−61".match(rex).captures
#=> ["東京都", "文京区", "後楽1丁目3−61"]





TL;DR





(...??[])((?:||||||||||||||||||||廿||||)|.+?(?:||.+?)[]|.+?.+?|.+?[])(.+)


使


便
 便  ( (zip) )

Ruby
  - Gist

CSV


0.00001
(.+?[都道府県])(.+?[市区町村])(.+)





: 
19989/123909 (16%)







34(...?[])

(.{2,3}?[])OK
(...??[都道府県])(.+?[市区町村])(.+)

: 
18220/123909 (14%)








(@jkr_2255)

166001200

(...??[都道府県])(.+?市.+?区|.+?[市区町村])(.+)

: 
2783/123909 (2%)



1200

[]




(...??[都道府県])(.+?郡.+?[町村]|.+?市.+?区|.+?[市区町村])(.+)

: 
2205/123909 (1%)






 


(?:||||||||||||||||||||廿||||)



廿()



(...??[])((?:||||||||||||||||||||廿||||)|.+?.+?[]|.+?.+?|.+?[])(.+)

: 
29/123909 (0%)


......

29 (0.0002%) 


2


||

||


[]
.+?[]{1,2}
(?:||.+?)[]




(...??[])((?:||||||||||||||||||||廿||||)|.+?(?:||.+?)[]|.+?.+?|.+?[])(.+)

: 
0/123909 (0%)


0




便(|)




 - Qiita

便  2005 2016

 - Uncyclopedia

1: 


...

-e



(3456)

60%
(.+?[])(.+?[])(.+)(16%)




2: 


210


(...??[])((?:||||||||||||||||||||廿|||||)|...?(?:||.{1,5}?)[]|(?:.{1,4})?.{1,4}?|.{1,7}?[])(.+)

: 
44 / 123909 (0%)


....


(...??[])((?:||||||||||||||||||||廿|||||)|(?:||[^]{2,3}?)(?:||.{1,5}?)[]|(?:.{1,4})?[^]{1,4}?|.{1,7}?[])(.+)

: 
20 / 123909 (0%)





(...??[])((?:||||||||||||||||||||廿|||||||||||||)|(?:||[^]{2,3}?)(?:||.{1,5}?)[]|(?:.{1,4})?[^]{1,4}?|.{1,7}?[])(.+)

: 
0 / 123909 (0%)



918
743
15

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

918
743