LoginSignup
29
31

More than 5 years have passed since last update.

正規表現の基本を習得する

Last updated at Posted at 2014-08-04

苦手意識を克服するためにまとめました。

文字クラス

文字クラス 説明
[abc] aかbかcのいずれか。
[a-z] aからzのいずれか。
[^a] aじゃない文字。
[^a-z] aからzじゃない文字。
(abc|def) abcまたはdef。
\n 改行。
\t タブ。
\d 数字。[0-9]
\w 英数字。[a-zA-Z0-9_]
\s スペース、タブ。

繰り返し

メタ文字 説明
. 任意の1文字。
? 直前を0回または1回繰り返す。
* 直前を0回以上繰り返す。
+ 直前を1回以上繰り返す。
{n} 直前をn回繰り返す。
{n,} 直前をn回以上繰り返す。
{n,m} 直前をnからm回以上繰り返す。

アンカー

メタ文字 説明
^ 行頭
$ 行末

参考リンク

29
31
1

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
29
31