0
0

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.

atomを利用してハイフンなしの携帯番号にハイフンを付与する置換方法

Last updated at Posted at 2018-05-03

やりたいこと。

atomを利用して携帯番号(ハイフンなし)から携帯番号(ハイフンあり)に置換する。

変更前

07012345678
07012345678
08012345678
08012345678
09012345678
09012345678

変更後

070-1234-5678
070-1234-5678
080-1234-5678
080-1234-5678
090-1234-5678
090-1234-5678

正規表現を置換に利用します。

セクセル等でする場合はこちら

atomの検索機能で正規表現を利用します。
image.png

ざっとこんな意味です。

正規表現 説明
^(0[789]0) 0から始まり7,8,9のどれかと0
[0-9]{4} 数字4桁

図だとこんな感じ
image.png

atomでは()で囲むとグループ分けされその部分を置換時に $1 $2 という感じで参照することができます。
その結果$1-$2-$3とすれば携帯番号(ハイフンあり)が作れます。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?