LoginSignup
0
1

More than 5 years have passed since last update.

正規表現 自分用メモ

Last updated at Posted at 2017-12-30

概要

自分がググったor使った正規表現をメモります

文字

半角英数字等(a~z,A~Z,_,1~9)

\w

ひらがな

\p{InHiragana}

カタカナ

\p{InKatakana}

漢字(色々な書かれ方があるが、コレが完璧で全てを含む)

[\x{2E80}-\x{2FDF}々〇〻\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}\x{20000}-\x{2FFFF}]

記号:!"#$%&'()*+,-./:;<=>?@[]^_`{

\p{Punct}

文字全体(半角英数字・ひらがな・カタカナ・漢字)

[\w\p{InHiragana}\p{InKatakana}\x{2E80}-\x{2FDF}々〇〻\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}\x{20000}-\x{2FFFF}]

Twitter

Twitter APIで取ってくるツイート本文の要素を取得

Twitterのハッシュタグ

(#[\w\p{InHiragana}\p{InKatakana}\x{2E80}-\x{2FDF}々〇〻\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}\x{20000}-\x{2FFFF}]+)

リプに含まれるユーザー名

@[a-zA-Z0-9_\-.]{3,15}: 

RTとその時に含まれるユーザー名

RT @[a-zA-Z0-9_\-.]{3,15}: 

その他

URL

(http|https)://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?

最後に

適宜正規表現を使い次第更新していこうと思います。

参考文献

基本的なことは全部ここに書いてある
(忘れっぽい人のための正規表現チートシート)
https://qiita.com/tossh/items/635aea9a529b9deb3038

(正規表現の基本)
https://qiita.com/sea_ship/items/7c8811b5cf37d700adc4

正規表現の組み合わせをまとめたチートシート
(よく使う正規表現はもうググりたくない!)
https://qiita.com/dongri/items/2a0a18e253eb5bf9edba

漢字について細かく書いてある
(Unicodeで「漢字」の正規表現)
http://tama-san.com/kanji-regex/

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