0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JavaScriptのserch()メソッド

Posted at

パターンマッチングする方法で、簡単なメソッドはserch()メソッドです。検索する文字列(正規表現)を引数にしているすると、最初に見つけた文字列の先頭の文字位置を表す数値を返します。マッチする文字が見つからない場合は-1を返します。

"hello world".search() // 0
"The quick brown fox jumps over the lazy dog".search("over") // 26
"abcdefghijklmnopqrstuvwxyz".search("s") // 18
"JavaScript".search(/script/ui) // 4
"Puthon".search(/script/ui)     // -1

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?