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.

ブログのタイトルからURLっぽいものを生成

Posted at

ブログのタイトルから半角文字のみを抽出し、ハイフンで繋いだ文字列を生成

def gen_title(str)
  str.downcase.scan(/[a-zA-z0-9]+/).map{|s| s.strip}.join('-')
end

gen_title '10分でnode.jsとangular JS, sassでリッチなWebサイトを作る'
# => 10-node-js-angular-js-sass-web
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?