JavaScript 文字列操作 新しいページはコチラ
提供: yonewiki
(→文字列検索(文字列変数後方検索) lastIndexOf) |
(→文字列正規表現検索(返却値が一致文字列) match) |
||
708行: | 708行: | ||
== '''文字列正規表現検索(返却値が一致文字列) match ''' == | == '''文字列正規表現検索(返却値が一致文字列) match ''' == | ||
+ | *strResult = strData19.match(/regular expression/) | ||
+ | |||
+ | 上記のようにして利用します。 | ||
+ | |||
+ | |||
+ | :*第一引数:正規表現パターンマッチ検索文字列 | ||
+ | |||
+ | |||
+ | サンプルスクリプト | ||
+ | <syntaxhighlight lang="javascript" line start="1"> | ||
+ | strData19 = new String("正規表現文字列検索(regular expression)"); | ||
+ | |||
+ | document.write(".match() : ",strData19, " ,検索結果 = ", strData19.match(/regular expression/), "</BR>"); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | 表示結果: | ||
+ | |||
+ | <yjavascript> | ||
+ | strData19 = new String("正規表現文字列検索(regular expression)"); | ||
+ | |||
+ | document.write(".match() : ",strData19, " ,検索結果 = ", strData19.match(/regular expression/), "</BR>"); | ||
+ | </yjavascript> | ||
== '''文字列正規表現検索(返却値が文字位置) search ''' == | == '''文字列正規表現検索(返却値が文字位置) search ''' == |