判定方法: 1. 構文 "str.includes(searchString[,position])" の include() を使用します; 2. 構文 "str.indexOf(substring)" の IndexOf() を使用します。 " -1" が返されます。使用できません。 3. 正規表現検索で test()、match()、または search() を使用します (構文 "exp.test(str)"、"str.match(exp)")。
このチュートリアルの動作環境: Windows 7 システム、ECMAScript バージョン 6、Dell G3 コンピューター。
#es6 文字列に部分文字列が含まれているかどうかを判断する方法
#方法 1: include() 関数を使用するES6 文字列には新しい include メソッドがあり、これを使用して部分文字列が含まれているかどうかを判断できます。
str.includes(searchString[, position])
- searchString: クエリの部分文字列
- position: オプション、検索を開始する位置、デフォルトは 0
-
'Blue Whale'.includes('Blue'); // returns true 'Blue Whale'.includes('blue'); // returns false
includes メソッドでは大文字と小文字が区別されることに注意してください。
es6 をサポートしていないブラウザの場合は、次のような es6-shim を追加できます。
require('es6-shim')方法 2:indexOf() 関数を使用します
indexOf これは、部分文字列が含まれているかどうかを判断するためによく使用される方法です。部分文字列が含まれている場合は部分文字列のインデックスを返し、それ以外の場合は -1 を返します。
var string = "foo", substring = "oo"; if(string.indexOf(substring) == -1) { console.log("不包含子字符串") } else { console.log("包含子字符串") }方法 3: 正規表現の使用
正規表現を使用するには、test、match、search
1、test## の 3 つの方法があります。 #
var string = "foo", exp = /oo/; var result = exp.test(string);test はブール値を返します。存在する場合は true、存在しない場合は false を返します。 テスト関数の呼び出し元は正規表現であることに注意してください。 2, match
var string = "foo", exp = /oo/; var result = string.match(exp); console.log(result);出力結果:
["oo", index: 1, input: "foo"]呼び出し元は文字列で、一致した場合は、正規表現、インデックス、および一致した内容を含む配列が返されます。入力。 3. search
var string = "foo", exp = /oo/; var result = string.search(exp);は、検索された部分文字列のインデックスを返します。検索が見つからない場合は、-1 が返されます [関連する推奨事項:
JavaScript ビデオ チュートリアル
、ウェブ フロントエンド ]
以上がes6の文字列に特定の文字列があるかどうかを判断する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

クラスセレクターとIDセレクターの使用は、特定のユースケースに依存します。1)クラスセレクターは、マルチエレメント、再利用可能なスタイル、2)IDセレクターは、ユニークな要素と特定のスタイルに適しています。クラスセレクターはより柔軟であり、IDセレクターは処理が速くなりますが、コードメンテナンスに影響を与える可能性があります。

KeygoalgoalgoalsandMotivationbehindhtml5weretoenhancesemanticsturuture、revevemultimediasupport、andensurebetterbetterperformance andcompativibulyacrossdevices、riveneedddresshtml4'slimitationsandmeetmeetmeetmodernwebdurvessmuntmunts.1)

idsareuniqueandusedforsingleelements、whileclasseSarereuresableformultiplements.1)useidsforuniqueelementslikeaspecificheader.2)useclassess forconsistentstylingacrossmultipleementslikebuttons.3)usecidsidsoverridecs.4)

html5aimstoenhancewebaccessibility、Interactionivity、およびefficiency.1)itupportsMultimediawithoutplugins、SimplifyifyifiedUeRexperience.2)SemanticMarkimprovestureandAccessibility.3)強化されたファームハンドリングインクレースの使用可能性

HTML5ISNOTPARTICULALLYLYDIFFICULTTOUSE BUTRESSTINGSINTINGSITSITURES.1)semanticelementslikelikelike like ,, and and -revestructure、and readability、seo、andacessibility.2)MultimediasupportviaandelementshanceSususeRexperiencewithoutplugins.3)

いいえ、あなたはusemultipleidsinthemedom.1)idsmustbeuniqueperhtmlspecification、およびusingdusing cansistent browserbehavior.2)useclassesses forstylingmultipleElements、acturtorectorectorectorsectorgettributeurutuureのuseclasses forstyling forstyling forstyling forstyling forstyling forstyling rassess for -destendertantertorectorsutortortortruture

html5aimstoenhancewebcapability、makingmoredynamic、interactive、およびaccessible.1)itupportsmultimediaelementslikeand、排除、2)semanticelementionmentionmentionmentionimementsimementionimementsimementsimbrovecessibilityandcodereadability.3)

html5aimstoenhancewebdevelymentanduserexperiencetheTheTheTheTheTheTheTheTheTructure、multimedieingegration、およびperformanceImprovements.1)semanticelementslike like like ,, and and requrovedababilityandaccessibility.2)andTagsallowseamlessmultimediaemdiding withoutplugins.3)


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

SublimeText3 Linux 新バージョン
SublimeText3 Linux 最新バージョン

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

メモ帳++7.3.1
使いやすく無料のコードエディター

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

Safe Exam Browser
Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。
