0
1

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.

Regex

Posted at

Regexについて

Regexとは正規表現(Regular Expression)のことで、記号を使って高度な検索条件を与える表現技法です。

記号 意味 マッチする 同様
^ 行頭を表す ^asd asdfgh,asdzxc,
$ 行末を表す asd$ qweasd,zxcasd,
. 任意の一字を意味する a.s ads,ahs,
* 直前文字の0回以上の繰り替えし as* a,ass,assss,
+ 1回以上の繰り返し as+ as,ass,asssss,
? 0回または1回 as? a,as
{m} m回の繰り返し a{3} aaa
{m,n} m~n回の繰り返し a{3,5} aaa,aaaa,aaaaa
[...] ...のなかの任意の一字を意味する [asd] a,s,d
[^...] ...の文字が含まれないことを意味する [^asd] q,w,e,
[a-d] aからdまで [a-d] a,b,c,d
| or a|d a,d
|正規表現の記号をエスケープする
() グループ化 (asd)+ asd,asdasd,asdasdasd,
\d 1つの半角数字 [0-9]
\D 任意の数字以外 [^0-9]
\s 任意の空白文字 [\t\n\r\f\v]
\S 任意の空白文字以外 [^\t\n\r\f\v]
\w 任意の英数字 [a-zA-Z0-9_]
\W 任意の英数字以外 [^a-zA-Z0-9_]
\A 文字列の先頭 ^
\Z 文字列の末尾 $
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?