LoginSignup
0
1

More than 1 year has passed since last update.

正規表現(まずはこれだけ)

Last updated at Posted at 2021-06-18

はじめに

目次

  1. 文字コード
  2. 基本

文字コード

文字コード 内容 対応する表現
\r\n 改行(Windows)
\n 改行(UNIX系, MacOS(v10~))
\d 数字 [0-9]
\s 空白文字(半角空白,タブ,改行,改ページ) [ \t\r\n\f]
\S 空白文字以外 [^ \t\r\n\f]
\w アルファベット,数字,アンダーバー [a-zA-Z0-9_]
\W アルファベット,数字,アンダーバー以外 [^a-zA-Z0-9_]
^ 先頭
$ 末尾
< 単語先頭
> 単語末尾
\A ファイル先頭
\z ファイル末尾

基本

正規表現 内容
. 1文字
+ 1回以上繰り返し最長一致
+? 1回以上繰り返し最短一致
* 0回以上繰り返し
*? 0回以上繰り返し最短一致
[abc] a,b,cいずれか1文字
[^abc] a,b,c以外
aaa bbb
[ メタ文字を検索するときは\をつける
int 整数
float 単精度浮動小数点数
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