ホームページ ウェブフロントエンド jsチュートリアル JS の RegExp オブジェクト オブジェクト Regular_JavaScript スキル

JS の RegExp オブジェクト オブジェクト Regular_JavaScript スキル

May 16, 2016 pm 05:48 PM
regexp 通常

RegExp オブジェクトのインスタンスを作成するには 2 つの方法があります。

RegExp の明示的なコンストラクターを使用します。構文は new RegExp("pattern"[,"flags"]) です。
RegExp の暗黙的コンストラクターをプレーン テキスト形式で使用します: /pattern/[flags]。

パターン部分は、使用される正規表現パターンのテキストであり、必須です。最初の方法では、パターン部分は JavaScript 文字列の形式で存在し、二重引用符または一重引用符で囲む必要があります。2 つ目の方法では、パターン部分は 2 つの「/」でネストされており、引用符は使用できません。 。

flags 部分は、正規表現のフラグ情報を設定します (オプション)。フラグ部分が設定されている場合、最初の方法では文字列の形式で存在し、2 番目の方法では最後の「/」文字の直後のテキストの形式で存在します。 flags には、次のフラグ文字を組み合わせて指定できます。
g はグローバルフラグです。このフラグが設定されている場合、テキストに対する検索と置換の操作は、テキストの一致するすべての部分に影響します。このフラグが設定されていない場合は、最も古い一致のみが検索され、置換されます。

i は大文字と小文字を無視するフラグです。このフラグが設定されている場合、一致比較を行うときに大文字と小文字が無視されます。

m は複数行のフラグです。このフラグが設定されていない場合、メタキャラクタ「^」は検索文字列全体の先頭のみと一致し、メタキャラクタ「$」は検索文字列の末尾のみと一致します。このフラグが設定されている場合、「^」を「」と組み合わせることもできます。 "または" " は後の位置 (つまり、次の行の先頭) に一致し、"$" も " に一致します。 "または" " は、" の後の位置 (つまり、次の行の末尾) に一致します。

コード 1.1 は、正規表現を作成する例です。
コード 1.1 正規表現を作成します。 1.1.htm

コードをコピー コードは次のとおりです。

;head>
正規表現の作成

;



上記のコードの実行結果を図 8.1 に示します。
JavaScript 文字列の "" はエスケープ文字であるため、明示的に使用します。コンストラクターが RegExp インスタンス オブジェクトを作成する場合、元の正規表現の "" は "" に置き換えられます。たとえば、コード 1.2 の 2 つのステートメントは同等です。
コード 1.2 の "" はエスケープされます。



コードをコピー コードは次のとおりです:


正規表現パターンテキスト内のエスケープ文字も「"」であるため、正規表現内でリテラル文字「"」を照合する場合は、明示的に使用する場合は正規表現パターンテキスト内で「"」で表現する必要があります。構築 関数を使用して RegExp インスタンス オブジェクトを作成する場合、リテラル文字 "" を表すために "\" を使用する必要があります。
var re = 新しい RegExp(\\)。

1 RegExp オブジェクトのプロパティ

RegExp オブジェクトのプロパティは、静的プロパティとインスタンス プロパティに分けられます。以下に個別に紹介します。

1.1 静的属性
(1) インデックス属性。これは、現在の表現パターンの最初に一致するコンテンツの開始位置です (0 から数えます)。初期値は -1 で、一致が成功するたびにインデックス属性がそれに応じて変更されます。
(2) 入力属性。処理対象の現在の文字列を返します。これは $_ と省略できます。初期値は空の文字列 "" です。
(3)lastIndex 属性。現在の表現パターンが最初に一致するコンテンツ内の最後の文字の次の位置です。カウントは 0 から始まります。初期値は -1 で、検索を継続することを意味します。開始位置から開始され、一致するたびに、それに応じて lastIndex 属性値が変更されます。
(4)lastMatch 属性。現在の式パターンの最後に一致する文字列です。$& と省略できます。初期値は空の文字列「」です。 lastMatch 属性の値は、一致が成功するたびに変化します。
(5)lastParen 属性。式パターン内に囲まれた部分一致がある場合、それは現在の式パターン内の最後の部分一致と一致する部分文字列であり、$ と省略できます。初期値は空の文字列「」です。 lastParen 属性の値は、一致が成功するたびに変化します。
(6) leftContext 属性。現在の式パターンで最後に一致する文字列の左側にあるすべての文字列であり、$` と省略できます (「'」はキーボードの「Esc」の下にある逆引用符です)。初期値は空文字列「」です。一致が成功するたびに、そのプロパティ値が変化します。
(7) rightContext 属性。これは、現在の式パターンで最後に一致する文字列の右側にあるすべてのものであり、$' と省略できます。初期値は空文字列「」です。一致が成功するたびに、そのプロパティ値が変化します。
(8) $1…$9 の属性。これらのプロパティは読み取り専用です。式パターン内に囲まれたサブマッチがある場合、$1...$9 属性値は、それぞれ最初から 9 番目のサブマッチによってキャプチャされた内容になります。 9 個を超える部分一致がある場合、$1...$9 属性はそれぞれ最後の 9 個の部分一致に対応します。式パターンでは、括弧で囲まれたサブマッチをいくつでも指定できますが、RegExp オブジェクトは最後の 9 つのサブマッチの結果のみを保存できます。 RegExp インスタンス オブジェクトの一部のメソッドによって返される結果配列では、括弧内のすべての部分一致結果を取得できます。

1.2 インスタンス属性

(1) グローバル属性。 RegExp オブジェクト インスタンスの作成時に指定されたグローバル フラグ (g) のステータスを返します。 RegExp オブジェクト インスタンスの作成時に g フラグが設定されている場合、このプロパティは True を返します。それ以外の場合、デフォルト値は False を返します。
(2)ignoreCase 属性。 RegExp オブジェクト インスタンスの作成時に指定されたignoreCase フラグ (i) のステータスを返します。 RegExp オブジェクト インスタンスの作成時に i フラグが設定されている場合、このプロパティは True を返します。それ以外の場合、デフォルト値は False を返します。
(3) multiLine 属性。 RegExp オブジェクト インスタンスの作成時に指定された multiLine フラグ (m) のステータスを返します。 RegExp オブジェクト インスタンスの作成時に m フラグが設定されている場合、このプロパティは True を返します。それ以外の場合、デフォルト値は False を返します。
(4) ソース属性。 RegExp オブジェクト インスタンスの作成時に指定された式テキスト文字列を返します。

JS の RegExp オブジェクト (2)

2 RegExp オブジェクトのメソッド
RegExp オブジェクトの一般的なメソッドには、test、exec、compile があります。の機能と使い方を紹介します。最後に、RegExp オブジェクトのプロパティとメソッドの包括的な例を示します。
2.1 テストメソッド
構文形式は test(str) です。このメソッドは、RegExp オブジェクト インスタンスの作成時に指定された式パターンが文字列内に存在するかどうかを確認し、存在する場合は True を返し、存在しない場合は False を返します。一致が見つかった場合、RegExp オブジェクト内の関連する静的プロパティが更新されて、一致が反映されます。
2.2 exec メソッド
構文形式は exec(str) です。このメソッドは、RegExp オブジェクト インスタンスの作成時に指定された式パターンを使用して文字列を検索し、検索結果を含む配列を返します。
正規表現にグローバル フラグ (g) が設定されている場合は、exec メソッドと test メソッドを複数回呼び出して、そのたびに lastIndex で指定された位置から文字の検索を開始することで、文字列内で継続的な検索を実行できます。 RegExp オブジェクト文字列の属性値。
グローバル フラグ (g) が設定されていない場合、exec メソッドと test メソッドは RegExp オブジェクトの lastIndex 属性値を無視し、文字列の先頭から検索を開始します。
exec メソッドで一致が見つからない場合、戻り値は null になります。一致が見つかった場合は、配列が返され、その一致を反映するように RegExp オブジェクト内の関連する静的プロパティが更新されます。返された配列の要素 0 には完全な一致結果が含まれ、要素 1 ~ n は式パターンで定義された各部分一致の結果です。
exec メソッドによって返される配列には、input、index、lastIndex という 3 つの属性があります。
入力属性は、検索される文字列全体です。
index 属性は、検索文字列全体内の一致する位置を参照します。
lastIndex 属性は、一致した部分文字列の最後の文字の次の文字位置を参照します。
コード 2.1 は、このメソッドの応用例です。
コード 2.1 exec() メソッドの適用: 2.1.htm
コードをコピー コードは次のとおりです。 🎜>

exec() メソッド <br><script language = "JavaScript"> >var myString="aaa 111 bbb 222 ccc 1111 222ddd"; <br>var regex = /111/; //正規表現オブジェクトを作成します<br>var array=regex.exec(myString); ){ <br>var str="一致する部分文字列が見つかりました!" "n返される配列の値は次のとおりです:" array "n配列要素の数:" <br> array.length "n検索された文字列は次のとおりです:" input <br> "n 個の一致する部分文字列の開始位置は次のとおりです。" array.index <br> "n 個の一致する部分文字列の後の最初の文字の位置は次のとおりです。" regex.lastIndex; <br>} else{ <br>alert("一致する部分文字列が見つかりません!!"); <br></script> <br> </html> <br><br> <br><br>2.3 コンパイル方法 <br><br><br>構文形式は、compile("pattern"[,"flags"]) です。このメソッドは、RegExp オブジェクト インスタンスによって使用される表現パターンを置き換え、新しい表現パターンを内部形式にコンパイルして、後続の一致プロセスを高速化します。式をループ内で再利用する場合は、式をコンパイルすると実行速度が向上します。ただし、プログラム内で他の式パターンが使用された後に、最初にコンパイルされた式パターンが使用される場合、このようなコンパイルによる利点はありません。 <br><br> </div>2.4 包括的な例 <br><strong><br>コード 2.2 は、RegExp オブジェクトの包括的な例です。コードとその演算結果を注意深く分析すると、RegExp オブジェクトをより深く理解できます。 </strong>コード 2.2 RegExp オブジェクトの使用法: 2.2.htm <br><br><br><strong><br>コードをコピー </strong><br><br> コードは次のとおりです: <br><div class="codetitle"> <span><script language="javascript"> <a style="CURSOR: pointer" data="79159" class="copybut" id="copybut79159" onclick="doCopy('code79159')">var strSrc = "xxa1b01c001yya2b02c002zz"; <u>var re = /a(d)b(d{2})c(d{3})/ gi; </u>var arr, count = 0; </a>while ((arr = re.exec(strSrc)) != null) </span>{ </div>displayResult(); displayResult() <div class="codebody" id="code79159">{ <br>document.write("<p>これは正規表現/" re.source "/gi を string<br>"" <BR> RegExp.input "" (count ) "検索結果: <br>"); <BR>document.write("RegExp.index は " RegExp.index "<br>"); <BR>document.write("RegExp. lastIndex は " RegExp.lastIndex "<br>"); <br>document.write("RegExp.lastMatch は " RegExp.lastMatch "<br>"); <BR>document.write("RegExp.lastParen は " RegExp. lastParen "<br>"); <br>document.write("RegExp.leftContext は " RegExp.leftContext "<br>"); <BR>document.write("RegExp.rightContext は " RegExp .rightContext " <br>"); <br>document.write("RegExp.$1 は " RegExp.$1 "<br>"); <BR>document.write("RegExp.$2 は " RegExp.$2 " <br>"); <br>document.write("RegExp.$3 は " RegExp.$3 "<br>"); <BR>document.write("RegExp.$4 は " RegExp.$4 "< ; br>"); <br>document.write("arr.index is " arr.index "<br>"); <BR>document.write("arr.input is " arr.input "<br> ; "); <BR>document.write("arr.lastIndex は " arr.lastIndex "<br>"); <BR>document.write("返された配列の要素数は " arr.length "< ; br>"); <br>document.write("返された配列の内容は ["]; <br>for(var i=0; i<arr.length i>{ <br> if(i < arr.length-1) <BR>document.write(""" arr[i] "","); <BR>else <BR>document.write(""" arr[i] " ")</p>"); <br>} <br>} <br></script></arr.length> </div> </div> </div> </div> <div class="wzconShengming_sp"> <div class="bzsmdiv_sp">このウェブサイトの声明</div> <div>この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。</div> </div> </div> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="2507867629"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div class="AI_ToolDetails_main4sR"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5902227090019525" data-ad-slot="3653428331" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <!-- <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>人気の記事</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780570.html" title="R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780641.html" title="R.E.P.O.最高のグラフィック設定" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.最高のグラフィック設定</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796785841.html" title="アサシンのクリードシャドウズ:シーシェルリドルソリューション" class="phpgenera_Details_mainR4_bottom_title">アサシンのクリードシャドウズ:シーシェルリドルソリューション</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780520.html" title="R.E.P.O.誰も聞こえない場合はオーディオを修正する方法" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.誰も聞こえない場合はオーディオを修正する方法</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796785857.html" title="Atomfallのクレーンコントロールキーカードを見つける場所" class="phpgenera_Details_mainR4_bottom_title">Atomfallのクレーンコントロールキーカードを見つける場所</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1週間前</span> <span>By DDD</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/article.html">もっと見る</a> </div> </div> </div> --> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>ホットAIツール</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411540686492.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undresser.AI Undress" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_title"> <h3>Undresser.AI Undress</h3> </a> <p>リアルなヌード写真を作成する AI 搭載アプリ</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411552797167.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Clothes Remover" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_title"> <h3>AI Clothes Remover</h3> </a> <p>写真から衣服を削除するオンライン AI ツール。</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173410641626608.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undress AI Tool" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_title"> <h3>Undress AI Tool</h3> </a> <p>脱衣画像を無料で</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411529149311.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Clothoff.io" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_title"> <h3>Clothoff.io</h3> </a> <p>AI衣類リムーバー</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/ai-hentai-generator" title="AI Hentai Generator" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173405034393877.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Hentai Generator" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/ai-hentai-generator" title="AI Hentai Generator" class="phpmain_tab2_mids_title"> <h3>AI Hentai Generator</h3> </a> <p>AIヘンタイを無料で生成します。</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/ai">もっと見る</a> </div> </div> </div> <script src="https://sw.php.cn/hezuo/cac1399ab368127f9b113b14eb3316d0.js" type="text/javascript"></script> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>人気の記事</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780570.html" title="R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780641.html" title="R.E.P.O.最高のグラフィック設定" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.最高のグラフィック設定</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796785841.html" title="アサシンのクリードシャドウズ:シーシェルリドルソリューション" class="phpgenera_Details_mainR4_bottom_title">アサシンのクリードシャドウズ:シーシェルリドルソリューション</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780520.html" title="R.E.P.O.誰も聞こえない場合はオーディオを修正する方法" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.誰も聞こえない場合はオーディオを修正する方法</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796785857.html" title="Atomfallのクレーンコントロールキーカードを見つける場所" class="phpgenera_Details_mainR4_bottom_title">Atomfallのクレーンコントロールキーカードを見つける場所</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1週間前</span> <span>By DDD</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/article.html">もっと見る</a> </div> </div> </div> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>ホットツール</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/92" title="メモ帳++7.3.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab96f0f39f7357.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="メモ帳++7.3.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/92" title="メモ帳++7.3.1" class="phpmain_tab2_mids_title"> <h3>メモ帳++7.3.1</h3> </a> <p>使いやすく無料のコードエディター</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/93" title="SublimeText3 中国語版" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97a3baad9677.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 中国語版" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/93" title="SublimeText3 中国語版" class="phpmain_tab2_mids_title"> <h3>SublimeText3 中国語版</h3> </a> <p>中国語版、とても使いやすい</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/121" title="ゼンドスタジオ 13.0.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97ecd1ab2670.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="ゼンドスタジオ 13.0.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/121" title="ゼンドスタジオ 13.0.1" class="phpmain_tab2_mids_title"> <h3>ゼンドスタジオ 13.0.1</h3> </a> <p>強力な PHP 統合開発環境</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/469" title="ドリームウィーバー CS6" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d0e0fc74683535.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="ドリームウィーバー CS6" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/469" title="ドリームウィーバー CS6" class="phpmain_tab2_mids_title"> <h3>ドリームウィーバー CS6</h3> </a> <p>ビジュアル Web 開発ツール</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d34035e2757995.png?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 Mac版" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_title"> <h3>SublimeText3 Mac版</h3> </a> <p>神レベルのコード編集ソフト(SublimeText3)</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/ai">もっと見る</a> </div> </div> </div> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>ホットトピック</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/gmailyxdlrkzn" title="Gmailメールのログイン入り口はどこですか?" class="phpgenera_Details_mainR4_bottom_title">Gmailメールのログイン入り口はどこですか?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>7444</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>15</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/cakephp-tutor" title="CakePHP チュートリアル" class="phpgenera_Details_mainR4_bottom_title">CakePHP チュートリアル</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1371</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>52</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/steamdzhmcssmgs" title="Steamのアカウント名の形式は何ですか" class="phpgenera_Details_mainR4_bottom_title">Steamのアカウント名の形式は何ですか</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>76</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>11</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/winactivationkeyper" title="Win11 Activation Key Permanent" class="phpgenera_Details_mainR4_bottom_title">Win11 Activation Key Permanent</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>39</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>19</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/newyorktimesdailybrief" title="NYTの接続はヒントと回答です" class="phpgenera_Details_mainR4_bottom_title">NYTの接続はヒントと回答です</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>10</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>6</span> </div> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/faq/zt">もっと見る</a> </div> </div> </div> </div> </div> <div class="Article_Details_main2"> <div class="phpgenera_Details_mainL4"> <div class="phpmain1_2_top"> <a href="javascript:void(0);" class="phpmain1_2_top_title">Related knowledge<img src="/static/imghw/index2_title2.png" alt="" /></a> </div> <div class="phpgenera_Details_mainL4_info"> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/503257.html" title="PHP正規表現で何かで始まる文字列を置換する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202303/24/2023032415131944301.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP正規表現で何かで始まる文字列を置換する方法" /> </a> <a href="https://www.php.cn/ja/faq/503257.html" title="PHP正規表現で何かで始まる文字列を置換する方法" class="phphistorical_Version2_mids_title">PHP正規表現で何かで始まる文字列を置換する方法</a> <span class="Articlelist_txts_time">Mar 24, 2023 pm 02:57 PM</span> <p class="Articlelist_txts_p">PHP 正規表現は、テキストの処理と変換のための強力なツールです。テキスト コンテンツを解析し、特定のパターンに従って置換またはインターセプトすることで、テキスト情報を効果的に管理できます。その中でも、正規表現の一般的な応用例は、特定の文字で始まる文字列を置換することです。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/1784611.html" title="Golang 正規表現を使用して複数の単語または文字列を照合するにはどうすればよいですか?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/887/227/171712275815411.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Golang 正規表現を使用して複数の単語または文字列を照合するにはどうすればよいですか?" /> </a> <a href="https://www.php.cn/ja/faq/1784611.html" title="Golang 正規表現を使用して複数の単語または文字列を照合するにはどうすればよいですか?" class="phphistorical_Version2_mids_title">Golang 正規表現を使用して複数の単語または文字列を照合するにはどうすればよいですか?</a> <span class="Articlelist_txts_time">May 31, 2024 am 10:32 AM</span> <p class="Articlelist_txts_p">Golang の正規表現では、パイプ文字 | を使用して複数の単語または文字列を一致させ、各オプションを論理 OR 式として区切ります。例: 「fox」または「dog」に一致します: fox|dog は「quick」、「brown」または「lazy」に一致します: (quick|brown|lazy) 「Go」、「Python」または「Java」に一致します: Go| Python |Java は単語または 4 桁の郵便番号と一致します: ([a-zA</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/501697.html" title="正規表現を使用してPHPで漢字を削除する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202303/03/2023030310082086567.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="正規表現を使用してPHPで漢字を削除する方法" /> </a> <a href="https://www.php.cn/ja/faq/501697.html" title="正規表現を使用してPHPで漢字を削除する方法" class="phphistorical_Version2_mids_title">正規表現を使用してPHPで漢字を削除する方法</a> <span class="Articlelist_txts_time">Mar 03, 2023 am 10:12 AM</span> <p class="Articlelist_txts_p">正規表現を使用して PHP で中国語を削除する方法: 1. PHP サンプル ファイルを作成する; 2. 中国語と英語を含む文字列を定義する; 3. "preg_replace('/([\x80-\xff]*)/i', '',$a);" 通常の方法では、クエリ結果から中国語の文字を削除できます。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/502688.html" title="通常のマッチングを使用してphpでhtmlタグを削除する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202303/21/2023032117374363506.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="通常のマッチングを使用してphpでhtmlタグを削除する方法" /> </a> <a href="https://www.php.cn/ja/faq/502688.html" title="通常のマッチングを使用してphpでhtmlタグを削除する方法" class="phphistorical_Version2_mids_title">通常のマッチングを使用してphpでhtmlタグを削除する方法</a> <span class="Articlelist_txts_time">Mar 21, 2023 pm 05:17 PM</span> <p class="Articlelist_txts_p">この記事では、PHP 正規表現を使用して HTML タグを削除し、HTML 文字列からプレーン テキスト コンテンツを抽出する方法を学びます。 HTML タグを削除する方法を示すために、まず HTML タグを含む文字列を定義しましょう。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/552700.html" title="MySQL の REGEXP と LIKE の違いは何ですか?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202305/30/2023053013580794045.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="MySQL の REGEXP と LIKE の違いは何ですか?" /> </a> <a href="https://www.php.cn/ja/faq/552700.html" title="MySQL の REGEXP と LIKE の違いは何ですか?" class="phphistorical_Version2_mids_title">MySQL の REGEXP と LIKE の違いは何ですか?</a> <span class="Articlelist_txts_time">May 30, 2023 pm 01:58 PM</span> <p class="Articlelist_txts_p">1. 一致する内容の違い。LIKE ではデータ全体が一致する必要があります。Like では、このフィールドのすべての内容が条件を満たす必要がありますが、REGEXP では部分一致のみが必要で、満たされるフラグメントは 1 つだけです。 2. 一致位置の違い: LIKE は列全体に一致します。一致したテキストが列値にある場合、LIKE はそれを見つけられず、対応する行は返されません (ワイルドカードが使用されない限り)。REGEXP は列値内にあります。一致するテキストが列値にある場合、REGEXP はそれを見つけ、対応する行が返され、REGEXP は列値全体と一致します (LIKE と同じ効果)。 3. SQL ステートメントは、LIKE マッチングとは異なるデータを返します。SQL ステートメント</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/721256.html" title="PHP 正規表現を使用して中国語置換関数を実装するためのヒントを共有する" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/887/227/171127423347329.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP 正規表現を使用して中国語置換関数を実装するためのヒントを共有する" /> </a> <a href="https://www.php.cn/ja/faq/721256.html" title="PHP 正規表現を使用して中国語置換関数を実装するためのヒントを共有する" class="phphistorical_Version2_mids_title">PHP 正規表現を使用して中国語置換関数を実装するためのヒントを共有する</a> <span class="Articlelist_txts_time">Mar 24, 2024 pm 05:57 PM</span> <p class="Articlelist_txts_p">PHP 正規表現を使用して中国語の置換機能を実装するためのヒントを共有する Web 開発では、中国語のコンテンツを置換する必要がある状況によく遭遇します。人気のサーバーサイド スクリプト言語として、PHP は中国語の置換を簡単に実現できる強力な正規表現機能を提供します。この記事では、正規表現を使用して PHP で中国語置換を実装するためのテクニックをいくつか紹介し、具体的なコード例を示します。 1. preg_replace 関数を使用して中国語置換を実装します PHP の preg_replace 関数を使用できます</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/625910.html" title="Go 言語ドキュメントの解釈: regexp.FindAllString 関数の詳細な説明" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/000/164/169907953293637.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Go 言語ドキュメントの解釈: regexp.FindAllString 関数の詳細な説明" /> </a> <a href="https://www.php.cn/ja/faq/625910.html" title="Go 言語ドキュメントの解釈: regexp.FindAllString 関数の詳細な説明" class="phphistorical_Version2_mids_title">Go 言語ドキュメントの解釈: regexp.FindAllString 関数の詳細な説明</a> <span class="Articlelist_txts_time">Nov 04, 2023 pm 02:32 PM</span> <p class="Articlelist_txts_p">Go言語文書解釈:regexp.FindAllString関数の詳細説明 正規表現はテキスト処理において重要な役割を果たします。 Go 言語は、正規表現操作をサポートするための regexp パッケージを提供します。その中でもregexp.FindAllString関数は重要な機能を持っており、この記事ではこの関数の使い方と対応するコード例を詳しく解説します。 regexp.FindAllString 関数の機能は、指定された文字列内の正規表現を含むすべての文字列を検索して返します。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/565530.html" title="PHP 正規表現を使用して URL が HTTPS プロトコルであるかどうかを確認する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/887/227/168756582112191.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP 正規表現を使用して URL が HTTPS プロトコルであるかどうかを確認する方法" /> </a> <a href="https://www.php.cn/ja/faq/565530.html" title="PHP 正規表現を使用して URL が HTTPS プロトコルであるかどうかを確認する方法" class="phphistorical_Version2_mids_title">PHP 正規表現を使用して URL が HTTPS プロトコルであるかどうかを確認する方法</a> <span class="Articlelist_txts_time">Jun 24, 2023 am 08:16 AM</span> <p class="Articlelist_txts_p">Web サイトのセキュリティはますます注目を集めており、HTTPS プロトコルを使用してデータ送信のセキュリティを確保することが、現在の Web サイト開発の重要な部分となっています。 PHP 開発において、正規表現を使用して URL が HTTPS プロトコルであるかどうかを確認するにはどうすればよいですか?ここで私たちはそれを知りに来ました。正規表現 正規表現は、ルールを記述するために使用される表現です。テキストを処理するための強力なツールであり、テキストの一致、検索、置換に広く使用されています。 PHP 開発では、正規表現を使用して URL 内の http と一致させることができます。</p> </div> </div> <a href="https://www.php.cn/ja/web-designer.html" class="phpgenera_Details_mainL4_botton"> <span>See all articles</span> <img src="/static/imghw/down_right.png" alt="" /> </a> </div> </div> </div> </main> <footer> <div class="footer"> <div class="footertop"> <img src="/static/imghw/logo.png" alt=""> <p>福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!</p> </div> <div class="footermid"> <a href="https://www.php.cn/ja/about/us.html">私たちについて</a> <a href="https://www.php.cn/ja/about/disclaimer.html">免責事項</a> <a href="https://www.php.cn/ja/update/article_0_1.html">Sitemap</a> </div> <div class="footerbottom"> <p> © php.cn All rights reserved </p> </div> </div> </footer> <input type="hidden" id="verifycode" value="/captcha.html"> <script>layui.use(['element', 'carousel'], function () {var element = layui.element;$ = layui.jquery;var carousel = layui.carousel;carousel.render({elem: '#test1', width: '100%', height: '330px', arrow: 'always'});$.getScript('/static/js/jquery.lazyload.min.js', function () {$("img").lazyload({placeholder: "/static/images/load.jpg", effect: "fadeIn", threshold: 200, skip_invisible: false});});});</script> <script src="/static/js/common_new.js"></script> <script type="text/javascript" src="/static/js/jquery.cookie.js?1744232714"></script> <script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script> <link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all' /> <script type='text/javascript' src='/static/js/viewer.min.js?1'></script> <script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script> <script type="text/javascript" src="/static/js/global.min.js?5.5.53"></script> <script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function () { var u = "https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u + 'matomo.php']); _paq.push(['setSiteId', '9']); var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s); })(); </script> <script> // top layui.use(function () { var util = layui.util; util.fixbar({ on: { mouseenter: function (type) { layer.tips(type, this, { tips: 4, fixed: true, }); }, mouseleave: function (type) { layer.closeAll("tips"); }, }, }); }); document.addEventListener("DOMContentLoaded", (event) => { // 定义一个函数来处理滚动链接的点击事件 function setupScrollLink(scrollLinkId, targetElementId) { const scrollLink = document.getElementById(scrollLinkId); const targetElement = document.getElementById(targetElementId); if (scrollLink && targetElement) { scrollLink.addEventListener("click", (e) => { e.preventDefault(); // 阻止默认链接行为 targetElement.scrollIntoView({ behavior: "smooth" }); // 平滑滚动到目标元素 }); } else { console.warn( `Either scroll link with ID '${scrollLinkId}' or target element with ID '${targetElementId}' not found.` ); } } // 使用该函数设置多个滚动链接 setupScrollLink("Article_Details_main1L2s_1", "article_main_title1"); setupScrollLink("Article_Details_main1L2s_2", "article_main_title2"); setupScrollLink("Article_Details_main1L2s_3", "article_main_title3"); setupScrollLink("Article_Details_main1L2s_4", "article_main_title4"); setupScrollLink("Article_Details_main1L2s_5", "article_main_title5"); setupScrollLink("Article_Details_main1L2s_6", "article_main_title6"); // 可以继续添加更多的滚动链接设置 }); window.addEventListener("scroll", function () { var fixedElement = document.getElementById("Article_Details_main1Lmain"); var scrollTop = window.scrollY || document.documentElement.scrollTop; // 兼容不同浏览器 var clientHeight = window.innerHeight || document.documentElement.clientHeight; // 视口高度 var scrollHeight = document.documentElement.scrollHeight; // 页面总高度 // 计算距离底部的距离 var distanceToBottom = scrollHeight - scrollTop - clientHeight; // 当距离底部小于或等于300px时,取消固定定位 if (distanceToBottom <= 980) { fixedElement.classList.remove("Article_Details_main1Lmain"); fixedElement.classList.add("Article_Details_main1Lmain_relative"); } else { // 否则,保持固定定位 fixedElement.classList.remove("Article_Details_main1Lmain_relative"); fixedElement.classList.add("Article_Details_main1Lmain"); } }); </script> </body> </html>