4
3

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.

正規表現メモ

4
Posted at

概要

dotinstallで正規表現を学習したのでメモ

内容

//

パターン この間に正規表現のパターンを入力する

[abc]

aかbかcの1文字

[a-z]

aからzの1文字

[^abc]

a,b,c以外の1文字

.a

任意の1文字+a

^0

行頭に0があるか

0$

行末に0があるか

0{3}

0が3文字->000

0{2,}

0が2文字以上->00,000,000000

0{2,4}

0がに文字以上4文字以下->00,000,0000

a?

aがある又はない-> , a

a*

aが0文字以上-> , a, aaaa

a+

aが1文字以上->a, aaa, aaaaa

(abc)*

abcが0回以上繰り返している

(abc|ef)*

abc又はefの文字列が0回以上繰り返している->abcabc, abcef

\n

改行

\t

タブ

\d

数字

\w

英数字又は_

\s

スペース又はタブ

/

バックスラッシュの後にメタ文字でメタ文字として扱う->/

/i

大文字小文字を区別しない

/g

全てのマッチした要素を配列で返す

/m
複数行の^,$(行頭や行末)に対応させる

dotinstall*?

一番最初に0回以上マッチするdotinstall

dotinstall+?

一番最初に1回以上マッチするdotinstall

/(.*?)@dotinstall.com/
console.log(RegExp, $1)

@dotinstallの前にある何かしらの最小の文字列を取ってくる

/<img[^<]?src[^<]?(http[s]?://.?[.jpg|.png|.gif|.jpeg]).*?<"/g

# 抜き出す文字列
var s = "@taguch, @koji, @dotinstall";


var re = s.match(/taguch/);
4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?