{"id":918,"date":"2022-03-10T21:30:50","date_gmt":"2022-03-10T13:30:50","guid":{"rendered":"http:\/\/www.henrycome.com\/wordpress\/?p=918"},"modified":"2022-03-10T22:01:02","modified_gmt":"2022-03-10T14:01:02","slug":"20220310213013-2","status":"publish","type":"post","link":"http:\/\/www.henrycome.com\/wordpress\/202203102130\/918","title":{"rendered":"P86-94-\u6b63\u5219\u8868\u8fbe\u5f0f.js"},"content":{"rendered":"<pre><code class=\"language-javascript\">\/*P86-\u6b63\u5219-\u521b\u5efa\u6b63\u5219\u8868\u8fbe\u5f0f*\/\n\/\/\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u7528\u6765\u8868\u8fbe\u5b57\u7b26\u4e32\u89c4\u5219\u548c\u6a21\u5f0f\u7684\n\/\/\u7528\u5b83\u5224\u65ad\u67d0\u4e9b\u5b57\u7b26\u4e32\u662f\u5426\u7b26\u5408\u67d0\u4e9b\u89c4\u5f8b\u6216\u89c4\u5219\n\/\/\u7528\u9014\u5f88\u5e7f\u6cdb\uff0c\u6bd4\u5982\u9a8c\u8bc1\u90ae\u7bb1\uff0c\u9a8c\u8bc1\u624b\u673a\u53f7\uff0c\u6709\u6ca1\u6709\u7279\u6b8a\u5b57\u7b26\u7b49\n\n\/*\u57fa\u672c\u5efa\u7acb\u548c\u4f7f\u7528\n\/\/\u5b57\u9762\u503c\u6216RegExp()\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u8c61\nvar str =&#039;where when what&#039;;\n\nvar re=\/wh\/;\/\/2\u4e2a\/\u5305\u88f9,\u5207\u8bb0\u4e0d\u7528\u4f7f\u7528&#039;&#039;\nvar re2 = new RegExp(&#039;wh&#039;);\/\/\u6b63\u5219\u8868\u8fbe\u5f0f\u4f5c\u4e3aRegExp()\u7684\u53c2\u6570\uff08\u5b57\u7b26\u4e32\u683c\u5f0f\uff09\n\n\/\/\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u4f7f\u7528\n\/\/exec()\u548ctest()\uff0c\u5206\u522b\u53cd\u56de\u5339\u914d\u503c\u548cboolean\u503c\uff08\u8868\u793a\u662f\u5426\u5339\u914d\u5230\uff09\n\/\/\u4f46\u662f\u53ea\u80fd\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5339\u914d\u5230\u51fa\u73b0\u7684\u4f4d\u7f6e,index:0\n\/\/VH\uff1a\uff1f\u8fd4\u56de\u503c\u662fobject\u7c7b\u578b\uff0c\u56e0\u4e3atypeof\u8fd4\u56deundefined\uff0cboolean\uff0cstring\uff0cnumber\uff0cobject\uff08\u542bnull\u5386\u53f2\u9057\u7559\u95ee\u9898\uff09\uff0cfunction\nconsole.log(re.exec(str));\/\/[&quot;wh&quot;, index: 0, input: &quot;where when what&quot;, groups: undefined]\nconsole.log(re.test(str));\/\/true\nconsole.log(typeof re.exec(str));\/\/object\n\nconsole.log(re2.exec(str));\/\/[&quot;wh&quot;, index: 0, input: &quot;where when what&quot;, groups: undefined]\nconsole.log(re2.test(str));\/\/true\n\/** *\/\n\n\/*\u641c\u7d22\u6574\u4e2a\u5b57\u7b26\u4e32\u4ece\u5934\u5230\u5c3e\uff0c\u8fd4\u56de\u6240\u6709\u5339\u914d\n\/\/\u6b63\u5219\u8868\u8fbe\u5f0f\u540e\u9762\u6dfb\u52a0g\uff0c\u7136\u540e\u91cd\u590d\u8c03\u7528exec()\uff0c\u5c31\u4f1a\u8fd4\u56de\u540e\u7eed\u5339\u914d\u5230\u7684\u4f4d\u7f6e\uff0c\u4e0d\u52a0g\uff0c\u6bcf\u6b21\u90fd\u4ece\u5934\u5f00\u59cb\n\/\/VH\uff1a\u4f46\u662f\u6ce8\u610f\u6b63\u5219\u5fc5\u987b\u8d4b\u503c\u7ed9\u53d8\u91cf\uff0c\u76f4\u63a5\u4f7f\u7528\u6b63\u5219\uff0c\u6bcf\u6b21\u90fd\u662f\u7b2c\u4e00\u6b21\uff0c\n\/\/VH\uff1a\u5982\u679c\u5339\u914d\u4e00\u5171\u67093\u4e2a\uff0c\u8c03\u75284\u6b21\u8fd4\u56denull\uff0c\u7b2c\u4e94\u6b21\u5f00\u59cb\u662f\u91cd\u65b0\u4ece\u5934\u5f00\u59cb\uff0c\u91cd\u590d\u7ed3\u679c\nvar str =&#039;where when what&#039;;\nvar re=\/wh\/g;\/\/\u5728\u659c\u6760\u5916\u9762\u6dfb\u52a0g\uff0c\u4e0d\u52a0g\uff0c\u6bcf\u6b21\u8c03\u7528\u90fd\u662f\u91cd\u65b0\u4ece\u5934\u67e5\nvar re2 = new RegExp(&#039;wh&#039;);\/\/\u8fd9\u79cd\u65b9\u5f0f\u5e94\u8be5\u600e\u4e48\u6dfb\u52a0g\u5462\uff1f\u8fd8\u662f\u6709\u5176\u4ed6\u65b9\u5f0f\u5462\uff1f\nconsole.log(re.exec(str));\/\/\u6807\u8bb032\nconsole.log(re.exec(str));\/\/\u6807\u8bb033\nconsole.log(re.exec(str));\/\/\u6807\u8bb034\nconsole.log(re.exec(str));\/\/\u6807\u8bb035\u8fd4\u56denull\uff0c\u8bf4\u660e\u5df2\u7ecf\u68c0\u7d22\u5230\u672b\u5c3e\u4e86\u3002\nconsole.log(re.exec(str));\/\/\u6807\u8bb036\u91cd\u590d\u7b2c\u4e00\u6b21\u7ed3\u679c\nconsole.log(\/wh\/g.exec(str));\/\/\u6807\u8bb037\/\/\u76f4\u63a5\u4f7f\u7528\u6b63\u5219\uff0c\u6b21\u6b21\u90fd\u662f\u7b2c\u4e00\u6b21\nconsole.log(\/wh\/g.exec(str));\/\/\u6807\u8bb038\/\/\u76f4\u63a5\u4f7f\u7528\u6b63\u5219\uff0c\u6b21\u6b21\u90fd\u662f\u7b2c\u4e00\u6b21\n\/*\nindex.js:32 [&quot;wh&quot;, index: 0, input: &quot;where when what&quot;, groups: undefined]\nindex.js:33 [&quot;wh&quot;, index: 6, input: &quot;where when what&quot;, groups: undefined]\nindex.js:34 [&quot;wh&quot;, index: 11, input: &quot;where when what&quot;, groups: undefined]\nindex.js:35 null\nindex.js:36 [&quot;wh&quot;, index: 0, input: &quot;where when what&quot;, groups: undefined]\nindex.js:37 [&quot;wh&quot;, index: 0, input: &quot;where when what&quot;, groups: undefined]\nindex.js:38 [&quot;wh&quot;, index: 0, input: &quot;where when what&quot;, groups: undefined]\n*\/\n\/** *\/\n\n\/*P87-\u6b63\u5219-\u5b57\u7b26\u5339\u914d\n\/\/\u6700\u7b80\u5355\u7684\u8bed\u6cd5\u5c31\u662f\u5339\u914d\u5b57\u7b26\uff0c\u82f1\u6587\u5b57\u6bcd\uff0c\u6570\u5b57\uff0c\u4e0b\u5212\u7ebf\u7b49\u7b49\n\/\/VH:\u6211\u6d4b\u8bd5\u4e86\u4e2d\u6587\u4e5f\u662f\u53ef\u4ee5\u7684\u3002\n\n\/\/\u5982\u4f55\u5339\u914d\u5230\u56de\u8f66\uff0ctab\u7b49\u7279\u6b8a\u5b57\u7b26\u5462\uff1f\u6bd4\u5982\u4e0b\u9762\u7684\u6a21\u677f\u5b57\u7b26\u4e32\u4f8b\u5b50\n\/\/\u6a21\u677f\u5b57\u7b26\u4e32\u4f8b\u5b50\nvar str = `This str contains 123\nCAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587`;\n\nconsole.log(\/T\/.test(str));\/\/true\nconsole.log(\/This\/.test(str));\/\/true\nconsole.log(\/Thiss\/.test(str));\/\/false\nconsole.log(\/12\/.test(str));\/\/true\nconsole.log(\/1234\/.test(str));\/\/false\nconsole.log(\/_-&amp;\/.test(str));\/\/true\n\n\/\/VH\uff1a\u505a\u4e00\u4e9b\u81ea\u5df1\u60f3\u5230\u7684\u6d4b\u8bd5\nconsole.log(\/\u4e2d\/.test(str));\/\/true\/\/VH\uff1a\u8865\u5145\u4e00\u4e2a\u6c49\u5b57\u5339\u914d\uff0c\u662f\u53ef\u4ee5\u7684\nconsole.log(\/\u5c0f\/.test(str));\/\/false\/\/VH:\u8bc1\u660e\u786e\u5b9e\u662f\u53ef\u4ee5\u5339\u914d\u6c49\u5b57\nconsole.log(\/\\n\/.test(str));\/\/true\/\/VH:\u4e0d\u663e\u793a\u5b57\u7b26\uff0c\u4f7f\u7528\u8f6c\u4e49\u5b57\u7b26\nconsole.log(\/h.s\/.test(str));\/\/true\/\/VH:\u4e0b\u8282\u8bb2\u5230\u7684&#039;\u7ea6\u5b9a\u901a\u914d\u7b26&#039;(\u6211\u7684\u79f0\u547c)\u4e5f\u53ef\u4f7f\u7528\n\nconsole.log(\/\u4e2d\/.exec(str));\/\/[&quot;\u4e2d&quot;, index: 60, input: &quot;This str contains 123\u21b5CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587&quot;, groups: undefined]\nconsole.log(\/\u5c0f\/.exec(str));\/\/null\nconsole.log(\/\\n\/.exec(str));\/\/[&quot;\u21b5&quot;, index: 21, input: &quot;This str contains 123\u21b5CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587&quot;, groups: undefined]\nconsole.log(\/h.s\/.exec(str));\/\/[&quot;his&quot;, index: 1, input: &quot;This str contains 123\u21b5CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587&quot;, groups: undefined]\n\/** *\/\n\n\/*P88-\u6b63\u5219-\u7279\u6b8a\u5b57\u7b26\u5339\u914d\n\/\/\u6807\u9898\u4e0d\u592a\u6070\u5f53\uff0c\u5e94\u8be5\u662f\u7ea6\u5b9a\u7684\u901a\u914d\u7b26\n\/\/\u4e0a\u8282\u9002\u7528\u4e8e\u5df2\u7ecf\u77e5\u9053\u9700\u8981\u88ab\u5339\u914d\u7684\u5b57\u7b26\uff0c\u5982\u679c\u5339\u914d\u4e00\u4e9b\u89c4\u5219\u6216\u6a21\u5f0f\u7684\u8bdd\uff0c\u9700\u8981\u7279\u6b8a\u7684\u7b26\u53f7\u6765\u8868\u793a\n\/\/str.match(\/\u6b63\u5219\/)\uff0c\u4e0d\u542bg\uff0c\u8fd4\u56de\u5339\u914d\u5230\u7684\u7b2c\u4e00\u4e2a\u76f8\u5173\u4fe1\u606f\uff0c\u7b49\u540c\u4e8e&quot;\u6b63\u5219.exec(str)&quot;\u7684\u6548\u679c\u3002\n\/\/str.match(\/\u6b63\u5219\/g)\uff0c\u542bg\uff0c\u8fd4\u56de\u5339\u914d\u5230\u7684\u503c\uff0c\u591a\u4e2a\u5c31\u8fd4\u56de\u6570\u7ec4\n\nvar str = `This str contains 123\nCAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587`;\n\n\/\/.\u4efb\u610f\u5355\u4e2a\u5b57\u7b26\uff08\u4e0d\u542b\\n,\\r\u5c31\u662f\u6362\u884c\u548c\u56de\u8f66\uff09\n\/\/match(\/\u6b63\u5219\/)\uff0c\u4e0d\u542bg\uff0c\u8fd4\u56de\u5339\u914d\u5230\u7684\u7b2c\u4e00\u4e2a\u76f8\u5173\u4fe1\u606f\uff0c\u7b49\u540c\u4e8e&quot;\u6b63\u5219.exec()&quot;\u7684\u6548\u679c\u3002\nconsole.log(str.match(\/Th.s\/));\/\/[&quot;This&quot;, index: 0, input: &quot;This str contains 123\u21b5CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587&quot;, groups: undefined]\n\n\/\/match(\/\u6b63\u5219\/g)\uff0c\u542bg\uff0c\u8fd4\u56de\u5339\u914d\u5230\u7684\u503c\uff0c\u591a\u4e2a\u5c31\u8fd4\u56de\u6570\u7ec4\nconsole.log(str.match(\/Th.s\/g));\/\/[&quot;This&quot;]\nconsole.log(str.match(\/1.3\/g));\/\/[&quot;123&quot;]\nconsole.log(str.match(\/\u4e2d.\/g));\/\/[&quot;\u4e2d\u6587&quot;]\n\n\/\/\u4ee5\u4e0b\u7ea6\u5b9a\u8f6c\u4e49\u5b57\u7b26\u8868\u8fbe\u7279\u5b9a\u5339\u914d\u8303\u56f4\uff0c\u82e5\u5927\u5199\uff0c\u542b\u4e49\u76f8\u53cd\n\/\/\\d\u548c\\D\u542b\u4e49\u76f8\u53cd\n\n\/\/\\d\u8868\u793a\u6570\u5b570-9\nconsole.log(str.match(\/\\d\/g));\/\/(3)\u00a0[&quot;1&quot;, &quot;2&quot;, &quot;3&quot;]\n\/\/\\w\u8868\u793a\u6570\u5b57\u5b57\u6bcd\u4e0b\u5212\u7ebfA-Za-z_0-9\nconsole.log(str.match(\/\\w\/g));\/\/(47)\u00a0[&quot;T&quot;, &quot;h&quot;, &quot;i&quot;, &quot;s&quot;, &quot;s&quot;, &quot;t&quot;, &quot;r&quot;, &quot;c&quot;, &quot;o&quot;, &quot;n&quot;, &quot;t&quot;, &quot;a&quot;, &quot;i&quot;, &quot;n&quot;, &quot;s&quot;, &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;C&quot;, &quot;A&quot;, &quot;P&quot;, &quot;I&quot;, &quot;T&quot;, &quot;A&quot;, &quot;L&quot;, &quot;I&quot;, &quot;Z&quot;, &quot;E&quot;, &quot;D&quot;, &quot;l&quot;, &quot;e&quot;, &quot;t&quot;, &quot;t&quot;, &quot;e&quot;, &quot;r&quot;, &quot;s&quot;, &quot;a&quot;, &quot;n&quot;, &quot;d&quot;, &quot;_&quot;, &quot;s&quot;, &quot;y&quot;, &quot;m&quot;, &quot;b&quot;, &quot;o&quot;, &quot;l&quot;, &quot;s&quot;]\n\/\/\\s\u8868\u793a\u7a7a\u683c\u548c\u65e0\u663e\u793a\u5b57\u7b26\uff08\\n,\\r,\\t\uff09\uff0c\u53c2\u8003https:\/\/blog.csdn.net\/jiang7701037\/article\/details\/80754163\nconsole.log(str.match(\/\\s\/g));\/\/(9)\u00a0[&quot; &quot;, &quot; &quot;, &quot; &quot;, &quot;\u21b5&quot;, &quot; &quot;, &quot; &quot;, &quot; &quot;, &quot; &quot;, &quot; &quot;]\nconsole.log(&#039;\u4f60\u597d&#039;.match(\/\\u4f60\/g));\/\/[&quot;\u4f60&quot;]\n\/\/\u5176\u5b9e\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u4e2d\u6587\uff0c\u800c\u4e14\u5fc5\u987b\u52a0g\uff0c\u624d\u80fd\u8fd4\u56de\u5339\u914d\u5230\u7684\u503c\u6570\u7ec4\uff0c\u4e0d\u7136\u5c31\u662f\u5339\u914d\u5230\u7684\u4f4d\u7f6e\u7b49\u4fe1\u606f\u6570\u7ec4\nconsole.log(&#039;\u4f60\u597d&#039;.match(\/\u4f60\/g));\/\/[&quot;\u4f60&quot;]\n\/** *\/\n\n\/*P89-\u6b63\u5219-\u5339\u914d\u6b21\u6570*\/\n\/\/\u53ef\u4ee5\u89c4\u5b9a\u67d0\u4e2a\u6a21\u5f0f\u51fa\u73b0\u591a\u5c11\u6b21\n\n\/\/*\u53f7\uff1a0\u6b21\u6216\u591a\u6b21\u3010\u56e0\u4e3a*\u5728\u6b63\u5219\u4e2d\u914d\u5408\/\u5f62\u6210\u6bb5\u843d\u6ce8\u91ca\u7b26\u540e\u534a\u90e8\u5206\uff0c\u6240\u4ee5*\u90e8\u5206\u8bb2\u89e3\u4f8b\u5b50console.log\u5168\u90e8\u4f7f\u7528\/\/\/\u6ce8\u91ca\u6389\uff0c\u65e5\u540e\u4f7f\u7528\uff0c\u641c\u7d22\/\/\/\u53ef\u4ee5\u53bb\u6389\u3011\nvar str = `This str contains 123\nCAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587`;\n\/\/\/console.log(str.match(\/This.*\/g));\/\/[&quot;This str contains 123&quot;]\n\/\/\u56e0\u4e3a.\u4e0d\u5339\u914d\u6362\u884c\uff0c\u6240\u4ee5\u4e0b\u9762\u66f4\u6539\u53d8\u91cf\u503c\uff0c\u5c31\u80fd\u5339\u914d\u5230\u6700\u540e\nvar str = `This str contains 123 CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587`;\n\/\/\/console.log(str.match(\/This.*\/g));\/\/[&quot;This str contains 123 CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587&quot;]\n\n\/\/\u601d\u80030\u6b21\nvar str = `This`;\n\/\/\/console.log(str.match(\/This.*\/g));\/\/[&quot;This&quot;]\n\/\/\u601d\u80031\u6b21\nvar str = `This1`;\n\/\/\/console.log(str.match(\/This.*\/g));\/\/[&quot;This1&quot;]\n\/\/\u601d\u80033\u6b21\nvar str = `This123`;\n\/\/\/console.log(str.match(\/This.*\/g));\/\/[&quot;This123&quot;]\n\/\/\u3010\u7ed3\u8bba\u3011\uff1a\u5339\u914d\u7ed3\u679c\u5e94\u8be5\u662f\u6700\u5927\u503c\uff08\u5b57\u7b26\u4e32\u5141\u8bb8\u7684\uff09\uff0c\u800c\u4e0d\u4f1a\u6839\u636e0,1,2,3\u8fd9\u6837\u4e0d\u505c\u53bb\u5339\u914d\n\n\/*+\u53f7\uff1a1\u6b21\u6216\u591a\u6b21\uff0c\u3010\u53ef\u4ee5\u7406\u89e3\u4e3a\u6b63\u6570\u6b21\u3011\nvar str = `This str contains 123 CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587`;\nconsole.log(str.match(\/t+\/g));\/\/(3)\u00a0[&quot;t&quot;, &quot;t&quot;, &quot;tt&quot;]\n\/\/\u3010\u7ed3\u8bba\u3011\uff1a+\u53ef\u4ee5\u6839\u636e1\u6b21\uff0c2\u6b21\uff0c3\u6b21\u8fd9\u6837\u7684\u53bb\u5339\u914d\uff0c\u4e0d\u662f\u6700\u5927\u503c\u6b21\u6570\n\/\/\u6d4b\u8bd5\u9694\u6b21\u6570\u51fa\u73b0\uff0c\u7ed3\u679c\u662f\u4f9d\u7136\u53ef\u4ee5\u3002\u4e0d\u4f1a\u56e0\u4e3a4\u6b21\u6ca1\u5339\u914d\u5230\u5c31\u7ed3\u675f\nvar str = `t tt ttt ttttt`;\/\/1235\nconsole.log(str.match(\/t+\/g));\/\/(4)\u00a0[&quot;t&quot;, &quot;tt&quot;, &quot;ttt&quot;, &quot;ttttt&quot;]\n\/** *\/\n\n\/*\uff1f\u8868\u793a1\u6b21\u62160\u6b21\n\/\/\u8fd9\u91cc\u53ef\u4ee5\u770b\u5230x?\u8fd4\u56de\u7ed3\u679c\u90fd\u662f\u7a7a\u5b57\u7b26\uff0c\u56e0\u4e3astr\u4e2d\u65e0x\uff0c\u7b26\u54080\u6b21\u6761\u4ef6\u88ab\u8fd4\u56de\uff0c\u4f46\u662f\u8fd9\u4e2a\u5339\u914d\u5230\u7684\u7ed3\u679c\u662f\u7a7a\n\/\/\u7b2c\u4e8c\u4e2aconsole.logt?,\u8fd4\u56de\u7ed3\u679c\u4e2d\u67091\u4e2a\u662f&#039;t&#039;\uff0c\u540c\u6837\u6b65\u9aa4\uff1a\u7b26\u54081\u6b21\u6761\u4ef6\uff0c\u8fd4\u56de\u5339\u914d\u5230\u7684\u7ed3\u679ct\nvar str = `This str contains 123 CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587`;\nconsole.log(str.match(\/x?\/g));\/\/(63)\u00a0[&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;]\nconsole.log(str.match(\/t?\/g));\/\/(63)\u00a0[&quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;t&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;t&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;t&quot;, &quot;t&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;]\n\/** *\/\n\/*\u7cbe\u786e\u91cd\u590d\u6b21\u6570\u7684\u65b9\u6cd5\uff1a{}\n\/\/{3}\u5355\u6570\u5b57\nvar str = `This str contains 12 345 67890 letters`;\nconsole.log(str.match(\/t{2}\/g));\/\/[&quot;tt&quot;]\nconsole.log(str.match(\/\\d{2}\/g));\/\/(4)\u00a0[&quot;12&quot;, &quot;34&quot;, &quot;67&quot;, &quot;89&quot;]\n\/\/{1,3}\u533a\u95f4\nvar str = `This str contains 12 345 67890 letters`;\nconsole.log(str.match(\/t{1,3}\/g));\/\/(3)\u00a0[&quot;t&quot;, &quot;t&quot;, &quot;tt&quot;]\nconsole.log(str.match(\/\\d{1,3}\/g));\/\/(4)\u00a0[&quot;12&quot;, &quot;345&quot;, &quot;678&quot;, &quot;90&quot;]\nconsole.log(str.match(\/\\d{1,2}\/g));\/\/(6)\u00a0\u00a0[&quot;12&quot;, &quot;34&quot;, &quot;5&quot;, &quot;67&quot;, &quot;89&quot;, &quot;0&quot;]\n\/\/VH\uff1a\u3010\u7ed3\u8bba\u3011\u5927\u6982\u662f\uff1a\n\/\/\u5148\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u6570\u5b57\u4e32\uff08\u4e00\u822c\u6709\u591a\u4e2a\uff09\uff0c\u4ece\u7b2c\u4e00\u4e32\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u5f00\u59cb\uff0c\n\/\/\u5148\u4ece\u6a21\u5f0f\u7684\u6700\u5927\u957f\u5ea6\u53bb\u5339\u914d\uff0c\u6210\u529f\uff0c\u5219\u7ee7\u7eed\u6d4b\u8bd5\u5269\u4f59\u90e8\u5206\uff0c\n\/\/\u5269\u4f59\u90e8\u5206\u5931\u8d25\uff0c\u9009\u62e9\u7b2c\u4e8c\u957f\u7684\u6a21\u5f0f\u53bb\u5339\u914d\uff0c\u4f9d\u6b21\u7c7b\u63a8\uff0c\u76f4\u5230\u6570\u5b57\u4e32\u7ed3\u675f\uff0c\u8df3\u5230\u4e0b\u4e00\u4e2a\u5b57\u7b26\u4e32\n\/\/\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u76f4\u5230\u6700\u540e\u5b57\u7b26\u4e32\u7684\u6700\u540e\u5b57\u7b26\u6d4b\u8bd5\u7ed3\u675f\n\n\/\/{1,}\u53ea\u6709\u5f00\u5934\u6570\u5b57+\u9017\u53f7\uff1a\u6700\u5c111\u6b21\nvar str = `This str contains 12 345 67890 letters`;\nconsole.log(str.match(\/\\d{1,}\/g));\/\/(3)\u00a0[&quot;12&quot;, &quot;345&quot;, &quot;67890&quot;]\n\/\/VH:\u3010\u89e3\u91ca\u3011\u201c\n\/\/1.\u201d\u627e\u5230\u6570\u5b57\u5c5e\u6027\u76843\u4e2a\u5b57\u7b26\u4e3212,345,67890\n\/\/2.\u5148\u4ece12\u5f00\u59cb\u6d4b\u8bd5\uff0c\u6700\u957f\u65e0\u9650\uff0c\u4e00\u76f4\u52302\u6b21\uff0c\u5339\u914d\u6210\u529f\uff0c\u672c\u5b57\u7b26\u4e32\u7ed3\u675f\uff0c\u8f6c\u5165\u4e0b\u4e00\u4e2a\n\/\/3.\u5f00\u59cb\u6d4b\u8bd5345,\u6700\u957f\u65e0\u9650\uff0c\u76f4\u52303\u6b21\uff0c\u5339\u914d\u6210\u529f\uff0c\u672c\u5b57\u7b26\u4e32\u7ed3\u675f\uff0c\u4e0d\u518d\u6d4b\u8bd5\u51fa\u73b02\u6b21\u7684\u60c5\u51b5\uff0c\u8f6c\u4e0b\u4e00\u4e2a\n\/\/4.\u5f00\u59cb\u6d4b\u8bd567890,\u6700\u957f\u65e0\u9650\uff0c\u76f4\u52305\u6b21\uff0c\u5339\u914d\u6210\u529f\uff0c\u672c\u5b57\u7b26\u4e32\u7ed3\u675f\uff0c\u4e0d\u518d\u6d4b\u8bd54\u6b21\u60c5\u51b5\uff0c\u540e\u7eed\u65e0\u6570\u5b57\u4e32\n\/\/5.\u7ed3\u675f\uff01\n\/** *\/\n\n\/*P90-\u6b63\u5219-\u533a\u95f4\u3001\u903b\u8f91\u548c\u754c\u5b9a\u7b26\nvar str = `This str contains 123 CAPITALIZED letters and _-&amp;^% symbols \u4e2d\u6587`;\n\nconsole.log(str.match(\/[abc]\/g));\/\/(4)\u00a0[&quot;c&quot;, &quot;a&quot;, &quot;a&quot;, &quot;b&quot;]\n\/\/\u53ef\u4ee5\u4f7f\u7528-\u4e2d\u5212\u7ebf\uff0c\u8868\u793a\u8fde\u7eed,\u4e0b\u4f8b\u5b50\u5c31\u662f\u6240\u6709\u7684\u5c0f\u5199\u5b57\u6bcd\u88ab\u5339\u914d\u5e76\u8fd4\u56de\nconsole.log(str.match(\/[a-z]\/g));\/\/(31)\u00a0[&quot;h&quot;, &quot;i&quot;, &quot;s&quot;, &quot;s&quot;, &quot;t&quot;, &quot;r&quot;, &quot;c&quot;, &quot;o&quot;, &quot;n&quot;, &quot;t&quot;, &quot;a&quot;, &quot;i&quot;, &quot;n&quot;, &quot;s&quot;, &quot;l&quot;, &quot;e&quot;, &quot;t&quot;, &quot;t&quot;, &quot;e&quot;, &quot;r&quot;, &quot;s&quot;, &quot;a&quot;, &quot;n&quot;, &quot;d&quot;, &quot;s&quot;, &quot;y&quot;, &quot;m&quot;, &quot;b&quot;, &quot;o&quot;, &quot;l&quot;, &quot;s&quot;]\n\/\/\u6240\u6709\u5927\u5199\u5b57\u6bcd\nconsole.log(str.match(\/[A-Z]\/g));\/\/(12)\u00a0[&quot;T&quot;, &quot;C&quot;, &quot;A&quot;, &quot;P&quot;, &quot;I&quot;, &quot;T&quot;, &quot;A&quot;, &quot;L&quot;, &quot;I&quot;, &quot;Z&quot;, &quot;E&quot;, &quot;D&quot;]\n\/\/\u6240\u6709\u6570\u5b57\nconsole.log(str.match(\/[0-9]\/g));\/\/(3)\u00a0[&quot;1&quot;, &quot;2&quot;, &quot;3&quot;]\n\/\/^\u8131\u5b57\u7b26\uff0c\u8868\u793a\u975e\u7684\u610f\u601d\u3002\n\/\/[^]\u91cc\u9762\u7684^\u5426\u5b9a\u5168\u90e8\u7684\u540e\u7eed\u5360\u4f4d\uff0c[^&lt;&gt;]\u4e0d\u542b&lt;\u548c&gt;2\u4e2a\u7b26\u53f7\uff0c\u5bf9\u6bd4\u50cf{}\u662f\u7d27\u6328\u7684\u524d\u97621\u4e2a\u5360\u4f4d\u7684\u6b21\u6570\n\/\/\uff08\u5360\u4f4d\u662f\u6211\u8d77\u7684\u540d\u5b57\uff0c\u610f\u601d\u662f\u5b8c\u6574\uff08\u8303\u56f4\uff09\u7684\u5b57\u7b26\u6216\u5b57\u7b26\u7ec4\u5408\uff09\n\/\/\u662f\u5426\u5fc5\u987b\u914d\u5408[]\u6765\u7528\u5462\uff1f\u5728\u5916\u9762\u662f\u4f5c\u4e3a\u5f00\u5934\u9650\u5b9a\u7b26\u7684\uff0c\u540e\u9762\u6709\u4f8b\u5b50\nconsole.log(str.match(\/[^0-9]\/g));\/\/(59)\u00a0[&quot;T&quot;, &quot;h&quot;, &quot;i&quot;, &quot;s&quot;, &quot; &quot;, &quot;s&quot;, &quot;t&quot;, &quot;r&quot;, &quot; &quot;, &quot;c&quot;, &quot;o&quot;, &quot;n&quot;, &quot;t&quot;, &quot;a&quot;, &quot;i&quot;, &quot;n&quot;, &quot;s&quot;, &quot; &quot;, &quot; &quot;, &quot;C&quot;, &quot;A&quot;, &quot;P&quot;, &quot;I&quot;, &quot;T&quot;, &quot;A&quot;, &quot;L&quot;, &quot;I&quot;, &quot;Z&quot;, &quot;E&quot;, &quot;D&quot;, &quot; &quot;, &quot;l&quot;, &quot;e&quot;, &quot;t&quot;, &quot;t&quot;, &quot;e&quot;, &quot;r&quot;, &quot;s&quot;, &quot; &quot;, &quot;a&quot;, &quot;n&quot;, &quot;d&quot;, &quot; &quot;, &quot;_&quot;, &quot;-&quot;, &quot;&amp;&quot;, &quot;^&quot;, &quot;%&quot;, &quot; &quot;, &quot;s&quot;, &quot;y&quot;, &quot;m&quot;, &quot;b&quot;, &quot;o&quot;, &quot;l&quot;, &quot;s&quot;, &quot; &quot;, &quot;\u4e2d&quot;, &quot;\u6587&quot;]\nconsole.log(str.match(\/[^a-z]\/g));\/\/(31)\u00a0[&quot;T&quot;, &quot; &quot;, &quot; &quot;, &quot; &quot;, &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot; &quot;, &quot;C&quot;, &quot;A&quot;, &quot;P&quot;, &quot;I&quot;, &quot;T&quot;, &quot;A&quot;, &quot;L&quot;, &quot;I&quot;, &quot;Z&quot;, &quot;E&quot;, &quot;D&quot;, &quot; &quot;, &quot; &quot;, &quot; &quot;, &quot;_&quot;, &quot;-&quot;, &quot;&amp;&quot;, &quot;^&quot;, &quot;%&quot;, &quot; &quot;, &quot; &quot;, &quot;\u4e2d&quot;, &quot;\u6587&quot;]\n\n\/\/[]\u5185\u4f7f\u7528-\u548c^\u7684\u672c\u4e49\uff0c\u5c31\u9700\u8981\u8f6c\u4e49\u7684\u5b57\u7b26\uff0c\u4e0b\u5212\u7ebf\u4e0d\u5fc5\u8f6c\u4e49\uff08\u548c[]\u65e0\u914d\u5408\uff09\nconsole.log(str.match(\/[\\-_&amp;\\^]\/g));\/\/(4)\u00a0[&quot;_&quot;, &quot;-&quot;, &quot;&amp;&quot;, &quot;^&quot;]\nconsole.log(str.match(\/\\-\/g));\/\/[&quot;-&quot;]\n\n\/\/\u6216\u7684\u903b\u8f91\nconsole.log(str.match(\/This|contains\/g));\/\/(2)\u00a0[&quot;This&quot;, &quot;contains&quot;]\n\n\/\/\u6307\u5b9a\u5f00\u5934\u6216\u7ed3\u5c3e^\u548c$\nvar str=`this that this and that`;\n\/\/\u76f4\u63a5this\uff0c2\u4e2a\u7ed3\u679c\uff0c\u4f7f\u7528^this,\u9650\u5b9a\u5728\u5f00\u5934\uff0c\u5c31\u4e00\u4e2a\u7ed3\u679c\nconsole.log(str.match(\/this\/g));\/\/(2)\u00a0[&quot;this&quot;, &quot;this&quot;]\nconsole.log(str.match(\/^this\/g));\/\/[&quot;this&quot;]\n\/\/\u76f4\u63a5that\uff0c2\u4e2a\u7ed3\u679c\uff0c\u4f7f\u7528that$,\u9650\u5b9a\u5728\u672b\u5c3e\uff0c\u53ea\u6709\u4e00\u4e2a\u7ed3\u679c\nconsole.log(str.match(\/that\/g));\/\/(2)\u00a0[&quot;that&quot;, &quot;that&quot;]\nconsole.log(str.match(\/that$\/g));\/\/[&quot;that&quot;]\nconsole.log(str.match(\/^that\/g));\/\/null\n\n\/\/\u5355\u8bcd\u8fb9\u754c\\b\nvar str=`this athata this and that`;\nconsole.log(str.match(\/that\/g));\/\/(2)\u00a0[&quot;that&quot;, &quot;that&quot;]\nconsole.log(str.match(\/\\bthat\\b\/g));\/\/[&quot;that&quot;]\n\/\/VH\uff1a\u8fd9\u4e0d\u5c31\u662f\u7a7a\u683c\u4e48\uff1f\nconsole.log(str.match(\/ that \/g));\/\/null\n\/\/VH:\u6539\u8fdb\uff0c\u53ea\u5728that\u524d\u9762\u52a0\u7a7a\u683c\nconsole.log(str.match(\/ that\/g));\/\/[&quot; that&quot;]\nconsole.log(str.match(\/\\bthis\\b\/g));\/\/(2)\u00a0[&quot;this&quot;, &quot;this&quot;]\nconsole.log(str.match(\/ this \/g));\/\/[&quot; this &quot;]\n\/\/\u3010\u603b\u7ed3\u3011\\b\u548c\u7a7a\u683c\u7684\u533a\u522b\uff0c\\b\u4e0d\u4f1a\u8fd4\u56de\u7a7a\u683c\uff0c\\b\u4ee3\u8868\u7a7a\u683c\u548c\u5f00\u5934\u6216\u7ed3\u5c3e\uff08\u8fd9\u4e24\u5904\u65e0\u7a7a\u683c\uff09\n\/** *\/\n\n\/*P91-\u6b63\u5219-\u5206\u7ec4*\/\n\/\/\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u4f7f\u7528\u5c0f\u62ec\u53f7\u5bf9\u6a21\u5f0f\u8fdb\u884c\u5206\u7ec4\n\/\/\u5206\u7ec4\u7684\u5185\u5bb9\u4f1a\u5f53\u6210\u4e00\u4e2a\u6574\u4f53\uff0c\u5e76\u4e14\u6267\u884c\u7684\u7ed3\u679c\u4f1a\u628a\u5206\u7ec4\u7684\u5185\u5bb9\u8fd4\u56de\u56de\u6765\u3002\n\n\/*\u4f8b\u5b501\n\/\/\u4f8b\u5b50\u4e2dth.*th\u5c31\u50cf\u62c9\u9762\uff0c2\u5934\u56fa\u5b9a\uff0c\u4e2d\u95f4\u53ef\u62c9\u4f38\u5339\u914d\u3002\n\/\/\u867d\u7136\u4e0d\u52a0\u62ec\u53f7\u4e5f\u80fd\u5339\u914d\uff0c\u4f46\u672c\u8282\u7684\u610f\u601d\u662f(th)\u4f5c\u4e3a\u6574\u4f53:1.\u6709()\u8fd4\u56de\u4fe1\u606f\u4e0d\u4e00\u6837\uff0c2.\u4f8b\u5b502\u66f4\u597d\u8bf4\u660e\u4f5c\u4e3a\u6574\u4f53\u7684\u542b\u4e49\nvar str = `this that this and that`;\nconsole.log(\/(th).*(th)\/.exec(str));\/\/(3)\u00a0[&quot;this that this and th&quot;, &quot;th&quot;, &quot;th&quot;, index: 0, input: &quot;this that this and that&quot;, groups: undefined]\nconsole.log(\/th.*th\/.exec(str));\/\/[&quot;this that this and th&quot;, index: 0, input: &quot;this that this and that&quot;, groups: undefined]\n\/*\n\u8001\u5e08\u8bf4\uff0c\u4f7f\u7528exec()\u53ef\u4ee5\u8fd4\u56de\u5206\u7ec4\u7684\u4e00\u4e9b\u4fe1\u606f\uff0cVH\uff1a\u7ecf\u8fc7\u6d4b\u8bd5\uff0c\u4e0d\u52a0()\u8fd4\u56de\u4fe1\u606f\u6ca1\u6709()\u5185\u7684th\u90e8\u5206\u3002\n\u8fd4\u56de\u7684\u7b2c\u4e00\u4e2a\u662f\u5339\u914d\u5230\u7684\u5b57\u7b26\u4e32\uff0c\u7b2c\u4e8c\u4e2a\u548c\u7b2c\u4e09\u4e2a\u5143\u7d20\u5bf9\u5e94\u6b63\u5219\u4e2d\u7684\u5206\u7ec4\u5185\u5bb9\uff01\n(3) [&quot;this that this and th&quot;, &quot;th&quot;, &quot;th&quot;, index: 0, input: &quot;this that this and that&quot;, groups: undefined]\n0: &quot;this that this and th&quot;\n1: &quot;th&quot;\n2: &quot;th&quot;\ngroups: undefined\nindex: 0\ninput: &quot;this that this and that&quot;\nlength: 3\n__proto__: Array(0)\n*\/\n\/** *\/\n\n\/*\u6d4b\u8bd5\u4f7f\u7528match()\n\/\/\u4ec5\u4ec5\u8fd4\u56de\u5339\u914d\u5230\u7684\u5b57\u7b26\u4e32\nvar str = `this that this and that`;\nconsole.log(str.match(\/(th).*(th)\/g));\/\/[&quot;this that this and th&quot;]\n\/** *\/\n\n\/*\u95ee\u7b54\u603b\u7ed3*\/\n\/\/\u95ee\uff1ath\u90a3\u4e48\u591a\uff0c\u4efb\u610f\u4e24\u4e2ath\u4e4b\u95f4\u4f5c\u4e3a\u4e00\u4e2a\u5339\u914d\uff0c\u4e3a\u5565\u53ea\u51fa\u4e00\u4e2a\u7ed3\u679c\u5462\uff1f\u6ca1\u52a0g\uff1f\u6ca1\u4f7f\u7528\u53d8\u91cf\uff1f\n\/\/\u7b54\uff1a\u56e0\u4e3a*\u662f\u4efb\u610f\u6b21\uff0c\u5339\u914d\u7684\u65f6\u5019\uff0c\u5148\u4ece\u6700\u957f\u5f00\u59cb\uff0c\u5339\u914d\u5230\u5c31\u5411\u540e\u5bfb\u627e\u3002\n\/\/\u95ee\uff1aexec()\u4e0d\u662f\u6267\u884c1\u6b21\u663e\u793a\u4e00\u4e2a\u4e48\uff1f\u800c\u4e14\u6ca1\u6709\u52a0g\uff1f\n\/\/\u7b54\uff1a\u56e0\u4e3a\u6700\u957f\u957f\u5ea6\u5339\u914d\uff0c\u53ea\u80fd\u67091\u4e2a\uff0c\u4e0d\u5fc5\u52a0g\uff08\u5168\u5c40\uff09\uff1b\n\n\/*\u81ea\u5df1\u4f8b\u5b50\u6d4b\u8bd5\n\/\/\u6362\u6210th\u548cnd\uff0c\u53d1\u73b0\uff0c\u53ea\u627e\u6700\u957f\u7684\u5339\u914d\u7ed3\u679c\uff0c\u8fd4\u56de\u6570\u7ec4\u5143\u7d203\u4e2a\uff0c\u5206\u522b\u662f[\u7ed3\u679c\uff0c(1),(2)].\n\/\/\u6ce8\u610f\uff1a\u53ea\u662fmatch()\u4e2d\u7684\u6b63\u5219\u52a0g\u662f\u8fd4\u56de\u7ed3\u679c\uff0c\u4e0d\u52a0g\u7b49\u4e8eexec()\u7684\u6548\u679c\uff0c\u8be6\u89c1\u7b2c88\u8282\u3002\nvar str = `this that nd this and that`;\nvar re =\/(th).*(nd)\/g;\/\/\nconsole.log(re.exec(str));\/\/(3)\u00a0[&quot;this that this and&quot;, &quot;th&quot;, &quot;nd&quot;, index: 0, input: &quot;this that this and that&quot;, groups: undefined]\nconsole.log(re.exec(str));\/\/null\nconsole.log(str.match(re));\/\/[&quot;this that nd this and&quot;]\n\/\/\u81ea\u5df1\u5199\u4e2a\u5c0f\u70b9\u7684\u4f8b\u5b50\nvar str = `th1nd`;\nvar re =\/(th).*(nd)\/g;\/\/\nconsole.log(re.exec(str));\/\/(3)\u00a0[&quot;th1nd&quot;, &quot;th&quot;, &quot;nd&quot;, index: 0, input: &quot;th1nd&quot;, groups: undefined]\nconsole.log(str.match(re));\/\/[&quot;th1nd&quot;]\n\/** *\/\n\n\/*\u8001\u5e08\u4f8b\u5b502\uff0c\u6709\u6548\u8bf4\u660e()\u4f5c\u4e3a\u6574\u4f53\u7684\u610f\u4e49\u3002\n\/\/\u8bbe\u5b9a\u51fa\u73b0\u6b21\u6570\u65f6\uff0caa\u4f5c\u4e3a\u6574\u4f53\u91cd\u590d\u51fa\u73b0\uff0c\u6bd4\u5982aaaa\n\/\/\u5982\u679c\u662faa{2},\u5c31\u662faaa\u8fd9\u6837\u7684\u4e86\u3002\nvar str =`aaaab abb cddaa`;\nconsole.log(str.match(\/(aa){2}\/g));\/\/[&quot;aaaa&quot;]\n\n\/\/\u8fd9\u5927\u6982\u7b49\u540c\u4e8e\/aaaa\/\uff0c\u7ecf\u8fc7\u6d4b\u8bd5\uff0c\u786e\u5b9a\u662f\u7684\u3002\nconsole.log(str.match(\/aaaa\/g));\/\/[&quot;aaaa&quot;]\n\n\/\/\u81ea\u5df1\u5199\u7684\u4f8b\u5b50\n\/\/\u6bd4\u5982\u52a0\u62ec\u53f7\uff0c\u6bd4\u5982(12){2}\uff0c\u5b9e\u4f8b\u5c31\u662f1212\n\/\/\u4e0d\u52a0\u62ec\u53f7\uff0c\u6bd4\u598212{2}\uff0c\u5b9e\u4f8b\u5c31\u662f122\nvar str =`1212 1221212`;\nconsole.log(str.match(\/(12){2}\/g));\/\/(2)\u00a0[&quot;1212&quot;, &quot;1212&quot;]\nconsole.log(str.match(\/12{2}\/g));\/\/[&quot;122&quot;]\n\/** *\/\n\n\/*P92-\u6b63\u5219-\u5e38\u89c1\u6b63\u5219\n\/\/\u65e5\u5e38\u5f00\u53d1\u4e2d\u6bd4\u8f83\u5e38\u89c1\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\n\/\/1.\u624b\u673a\u53f7\n\/\/var mobileRe = \/^1[3-9]{1}\\d{9}\/g;\/\/\u6211\u81ea\u5df1\u5199\u7684\u3002\nvar mobileRe = \/^1[3-9]\\d{9}\/g;\/\/\u8001\u5e08\u7684[3-9]\u540e\u9762\u6ca1\u6709\u8fd9\u4e2a{1}\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u5c31\u662f1\u3002\nconsole.log(mobileRe.test(&#039;13818886666&#039;));\/\/true\nconsole.log(mobileRe.test(&#039;10818886666&#039;));\/\/false\n\nvar mobileRe = \/^1[3-9]+\\d{9}\/g;\/\/+\u53f7\u662f\u51fa\u73b0\u6b21\u6570\u4e3a\u6b63\uff0c\u6709\u53ef\u80fd13\u540e\u7eed123456789\u5339\u914d\uff0c135\u540e\u7eed123456789\u4e5f\u5339\u914d\u3002\nconsole.log(mobileRe.test(&#039;135123456789&#039;));\/\/true\n\n\/\/2.\u90ae\u7bb1\n\/\/\u8fd9\u91cc\u6ce8\u610f\u89c2\u5bdf\u6b63\u5219\/\/g\u540e\u9762\u8fd9\u4e2ag\u7684\u989c\u8272\uff0c\u5982\u679c\u662f\u84dd\u8272\uff08\u5728vscode\u4e2d\uff09\u5c31\u8bf4\u660e\u57fa\u672c\u8bed\u6cd5\u5bf9\u3002\u5982\u679c\u662f\u5176\u4ed6\u989c\u8272\uff0c\u53ef\u80fd\u7b26\u53f7\u6216\u8005\u5199\u9519\u4e86\u3002\u6211\u5199\u6210\u4e86\u4e2d\u6587\u7684\uff08\uff09\nvar emailRe = \/^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$\/g;\nconsole.log(emailRe.test(&#039;admin@163.com&#039;));\/\/true\nconsole.log(emailRe.test(&#039;admin@163.comnnn&#039;));\/\/false\/\/\u56e0\u4e3a\u540e\u9762\u52a0\u4e863\u4e2an\u9020\u62106\u4e2a\u5b57\u7b26\n\n\/\/\u3010\u603b\u7ed3\u3011\n\/\/\u8fd9\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u80fd\u591f\u5f88\u597d\u7406\u89e3\u5230\uff0c\u6b63\u5219\u7684\u7528\u6cd5\u3002\u6b63\u5219\u7684\u6bcf\u4e2a\u5b57\u7b26\u5e76\u4e0d\u4ee3\u88681\u4e2a\u5b57\u7b26\uff0c\u800c\u662f\u81ea\u5df1\u6216\u8005\u4e0e\u5176\u4ed6\u5b57\u7b26\u7ec4\u5408\u6210\u4e00\u4e2a\u8303\u56f4\uff0c\n\/\/\u6309\u7167\u4e00\u4e2a\u8303\u56f4\u9ed8\u8ba4\u5360\u636e\u4e00\u4e2a\u5b57\u7b26\u4f4d\u7f6e\uff0c\u4e00\u4e2a\u8303\u56f4\u53ef\u4ee5\u6307\u5b9a\u51fa\u73b0\u6b21\u6570\uff0c\u590d\u5236\u81ea\u5df1\u5206\u8eab\u53bb\u5360\u4f4d\u7f6e\u3002=&gt;{}\n\/\/\u5177\u4f53\u4e3e\u4f8b\uff0ca\u8303\u56f4\u5c31\u662fa1\u4e2a\uff0ca-z\u4ee3\u886826\u4e2a\uff0c\n\/\/\u9ed8\u8ba4\u4e00\u5bb6\u4e00\u4efd\uff0c\u6d3e\u53601\u4e2a\u6210\u5458\u51fa\u6765\u5360\u4f4d\u7f6e1\u4e2a\uff0c(th)\u8868\u793a\u56fa\u5b9a\u7528t\u548ch\u7ec4\u5408\u6210\u5458\u5360\u4f4d\u7f6e\uff0c2\u4e2a\u6210\u5458\u62c9\u624b\u4e00\u8d77\u5360\u4f4d\u7f6e\uff0c1\u4efd2\u4e2a\u4f4d\u7f6e\u3002\n\/\/{2}\u91cd\u590d\u53602\u4efd\uff0c{2,5}\u5f39\u6027\u5360\u4f4d\uff0c\u53ef\u80fd2-5\u4efd\u3002\n\/\/^\u8868\u5f00\u5934\uff0c$\u8868\u7ed3\u5c3e\uff0c\u52a0\u5165\u961f\u5217\u3002\u56e0\u4e3a\u5b57\u7b26\u4e32\u5f00\u5934\u7ed3\u5c3e\u662f\u6982\u5ff5\u6027\u7684\u6ca1\u6709\u4f4d\u7f6e\uff0c\u6240\u4ee5\u8fd9\u4e24\u4e5f\u4e0d\u5360\u4f4d\uff0c\u5c31\u4e0d\u80fd\u91cd\u590d\n\/\/\u6ce8\u610f\u8f6c\u4e49\u3002\n\n\/\/3.\u7528\u6237\u540d\nvar usernameRe = \/^[a-zA-Z][a-zA-Z0-9_]{5,14}$\/g;\nconsole.log(usernameRe.test(&#039;abc&#039;));\/\/false\nconsole.log(usernameRe.test(&#039;$aaa&#039;));\/\/false\nconsole.log(usernameRe.test(&#039;abcd0_12a&#039;));\/\/true\nconsole.log(usernameRe.test(&#039;a123456789012345&#039;));\/\/false\/\/16\u4f4d\u4e86\u3002\nconsole.log(usernameRe.test(&#039;a12345678901234&#039;));\/\/true\/\/\u8fd9\u4e2a\u662f15\u4f4d\u3002\n\/** *\/\n\n\/*93-\u6b63\u5219-\u5b57\u7b26\u4e32\u66ff\u6362\n\/\/\u5b57\u7b26\u4e32\u91cc\u4e00\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u7528\u5230\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u3002\n\/\/replace()2\u4e2a\u53c2\u6570\uff0c\u88ab\u66ff\u6362\u90e8\u5206\u548c\u8981\u66ff\u8865\u4e0a\u53bb\u7684\u90e8\u5206\n\/\/replace()\u6709\u8fd4\u56de\u503c\uff0c\u662f\u5904\u7406\u540e\u7684\u65b0\u5b57\u7b26\u4e32\nvar str= &#039;Tish is an apple&#039;;\nconsole.log(str.replace(&#039;Tish&#039;,&#039;This&#039;));\/\/This is an apple\n\n\/\/\u4f7f\u7528\u6b63\u5219\nvar str= &#039;Tish 1is 2an 3apple&#039;;\nconsole.log(str.replace(\/\\d+\/g,&#039;&#039;));\/\/This is an apple\n\n\/\/VH\u6d4b\u8bd5\uff0c\u4e0d\u52a0g\nvar str= &#039;Tish 1is 2an 3apple&#039;;\nconsole.log(str.replace(\/\\d+\/,&#039;&#039;));\/\/Tish is 2an 3apple\/\/\u53ea\u66ff\u6362\u7b2c\u4e00\u4e2a\u5339\u914d\u5230\u7684\n\n\/\/VH\u6d4b\u8bd5\u591a\u4e2a\u6570\u5b57\uff0c\u5355\u72ec\u6570\u5b57\nvar str= &#039;Tish 1is 2an 333apple 5 34&#039;;\nconsole.log(str.replace(\/\\d+\/g,&#039;&#039;));\/\/Tish is an apple  \/\/\u591a\u4e2a\u548c\u5355\u72ec\u5747\u53ef\u66ff\u6362\uff0c\u524d\u9762apple\u540e\u9762\u662f\u6709\u7a7a\u683c\u7684\n\n\/\/\u590d\u6742\u4e00\u70b9\u7684\u4f8b\u5b50(\u8001\u5e08\u8bb2)\n\/\/\u4e0b\u9762\u6211\u662f\u65b0\u5efa\u53d8\u91cf\uff0c\u52063\u884c\u5199\u4ee3\u7801\uff0c\u4e3a\u4e86\u65b9\u4fbf\u8bf4\u660e\u6ce8\u610f\u70b9\uff0c\u8001\u5e08\u53ea\u7528\u4e86\u4e00\u884c\u3002\n\/\/\u8fd8\u6709\u6ce8\u610f\uff0c[^]\u91cc\u9762\u7684^\u5426\u5b9a\u5168\u90e8\u7684\u540e\u7eed\u5360\u4f4d\uff08\u5360\u4f4d\u662f\u6211\u8d77\u7684\u540d\u5b57\uff0c\u610f\u601d\u662f\u5b8c\u6574\uff08\u8303\u56f4\uff09\u7684\u5b57\u7b26\u6216\u5b57\u7b26\u7ec4\u5408\uff09\n\/\/\u672c\u4f8b\u4e2d\uff0c\u5e76\u4e0d\u662f\u4e00\u822c\u610f\u4e49\u7684\u66ff\u6362\uff0c\u800c\u662f\u6574\u4e2a\u5339\u914d\uff0c()\u9009\u4e2d\u8981\u4fdd\u7559\u7684\u90e8\u5206(\u5c31\u662f\u540e\u9762\u7684$1)\uff0c\u4ee5$1\u66ff\u6362\uff08\u5176\u5b9e\u5168\u5339\u914d\u5c31\u662f\u5168\u5220\u9664\uff0c\u4ee5$1\u66ff\u6362\u5c31\u662f\u4fdd\u7559$1\uff09\nvar html=`&lt;span&gt;hello&lt;\/span&gt;&lt;div&gt;world&lt;\/div&gt;`;\nre=\/&lt;[^&gt;]*&gt;([^&lt;&gt;]*)&lt;\\\/[^&gt;]*&gt;\/g;\/\/\u8fd9\u91cc\u8981\u6ce8\u610fhtml\u6807\u7b7e\u95ed\u6807\u7b7e\u7684\/\u9700\u8981\u8f6c\u4e49\uff0c\u4e0d\u7136\u5c31\u5f53\u6210\u6b63\u5219\u7684\u7ec4\u6210\u90e8\u5206\u4e86\u3002\nnewHtml= html.replace(re,&#039;$1&#039;);\/\/$1\u6307\u7684\u662f\u6b63\u5219\u4e2d\u7b2c\u4e00\u4e2a\u5206\u7ec4\u7684\u5185\u5bb9\uff0c\u800c\u4e14$1\u9700\u8981\u4f7f\u7528\u5f15\u53f7\uff01\u8bf4\u660e\u5b83\u4e0d\u662f\u53d8\u91cf\uff0c\u5c31\u662f\u8fd9\u91cc\u7279\u5b9a\u7b26\u53f7\uff01\nconsole.log(newHtml);\/\/helloworld\n\n\/\/\u6d4b\u8bd5$2\n\/\/\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\u7684\u6b63\u5219\u662f1\u5bf9\u6807\u7b7e\uff0c\u5b57\u7b26\u4e32\u662f\u4e24\u5bf9\u6807\u7b7e\u513f\u3002\u5339\u914d\u5230\u7b2c1\u5bf9\u540e\u3002\u7ee7\u7eed\u5f80\u540e\u5339\u914d\u7b2c2\u5bf9\u3002\n\/\/\u8fd9\u91cc\u662f\u628a\u4e0a\u9762\u7684\u6b63\u5219\u590d\u5236\u4e00\u904d\uff0c\u6b63\u597d\u5339\u914d\u6574\u4e2a\u5b57\u7b26\u4e32\uff01\n\/\/\u56e0\u4e3a\u67092\u5bf9\u6807\u7b7e\uff0c\u6240\u4ee5\uff0c\u6b63\u597d\u5b8c\u5168\u5339\u914d\nvar html=`&lt;span&gt;hello&lt;\/span&gt;&lt;div&gt;world&lt;\/div&gt;`;\nre=\/&lt;[^&gt;]*&gt;([^&lt;&gt;]*)&lt;\\\/[^&gt;]*&gt;&lt;[^&gt;]*&gt;([^&lt;&gt;]*)&lt;\\\/[^&gt;]*&gt;\/g;\nnewHtml= html.replace(re,&#039;$1&#039;+&#039;$2&#039;);\/\/$1\u6307\u7684\u662f\u6b63\u5219\u4e2d\u7b2c\u4e00\u4e2a\u5206\u7ec4\u7684\u5185\u5bb9\nconsole.log(newHtml);\/\/helloworld\nnewHtml= html.replace(re,&#039;$1&#039;+&#039;\u548c&#039;+&#039;$2&#039;);\/\/$1\u6307\u7684\u662f\u6b63\u5219\u4e2d\u7b2c\u4e00\u4e2a\u5206\u7ec4\u7684\u5185\u5bb9\nconsole.log(newHtml);\/\/hello\u548cworld\n\n\/\/\u6d4b\u8bd5\n\/\/\u8fd9\u6b21\u628a\u5b57\u7b26\u4e32\u7684\u6807\u7b7e\u5bf9\u4e3a3\u5bf9\uff0c\u8fd9\u4e2a\u65f6\u5019\uff0c\u80af\u5b9a\u5c31\u4e0d\u80fd\u5339\u914d\u7b2c3\u4e2a\nvar html=`&lt;span&gt;hello&lt;\/span&gt;&lt;div&gt;world&lt;\/div&gt;&lt;div&gt;\uff01&lt;\/div&gt;`;\nre=\/&lt;[^&gt;]*&gt;([^&lt;&gt;]*)&lt;\\\/[^&gt;]*&gt;&lt;[^&gt;]*&gt;([^&lt;&gt;]*)&lt;\\\/[^&gt;]*&gt;\/g;\nnewHtml= html.replace(re,&#039;$1&#039;+&#039;$2&#039;);\/\/$1\u6307\u7684\u662f\u6b63\u5219\u4e2d\u7b2c\u4e00\u4e2a\u5206\u7ec4\u7684\u5185\u5bb9\nconsole.log(newHtml);\/\/helloworld&lt;div&gt;\uff01&lt;\/div&gt;\n\/** *\/\n\n\/*P94-\u6b63\u5219-\u5b57\u7b26\u4e32\u5206\u79bb\n\/\/\u53e6\u5916\u4e00\u4e2a\u63a5\u6536\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u65b9\u6cd5\u662f\u5206\u9694\u5b57\u7b26\u4e32\/\/\u8001\u5e08\u8fd9\u91cc\u8bf4\u63a5\u6536\uff0c\u5e94\u8be5\u662f\u4ece\u53c2\u6570\u7684\u89d2\u5ea6\uff0c\u5b9e\u9645\u662f\u7528\u9014\u66f4\u6070\u5f53\u3002\n\/\/\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26\uff0c\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u5206\u9694\uff0c\u7136\u540e\u8fd4\u56de\u5206\u9694\u540e\u7684\u6570\u7ec4\n\nvar tags=&#039;html, css, javascript&#039;;\n\/\/\u6ce8\u610f\u8fd9\u4e2a\u9017\u53f7\u540e\u9762\u6709\u7a7a\u683c\uff0c\u5206\u9694\u51fa\u6765\u7684\u5143\u7d20\u5c31\u4e0d\u5e26\u7a7a\u683c\nconsole.log(tags.split(&#039;, &#039;));\/\/(3)\u00a0[&quot;html&quot;, &quot;css&quot;, &quot;javascript&quot;]\n\nvar str= &#039;This  | is , an &amp; apple&#039;;\n\/\/\\W\uff08\u5927\u5199W\uff09\u7684\u542b\u4e49\u662f\u975e\u5b57\u6bcd\u7684\uff0c+\u53f7\u7684\u610f\u601d\u662f\u6b63\u6570\u6b21\u91cd\u590d\u3002\u8fd9\u6837\uff0c\u5c31\u53ef\u4ee5\u5339\u914d\u5230\u591a\u4e2a\u7a7a\u683c\uff0c\u6807\u70b9\u7b26\u53f7\u7b49\nconsole.log(str.split(\/\\W+\/g));\/\/(4)\u00a0[&quot;This&quot;, &quot;is&quot;, &quot;an&quot;, &quot;apple&quot;]\n\n\/\/\u5982\u679c\\w(\u5c0f\u5199w\uff09\u7684\u542b\u4e49\u662f\u5b57\u6bcd\u7684\uff0c+\u53f7\u7684\u610f\u601d\u662f\u6b63\u6570\u6b21\u91cd\u590d\u3002\u8fd9\u6837\uff0c\u7ed3\u679c\u5c31\u76f8\u53cd\u4e86\nvar str= &#039;This  | is , an &amp; apple&#039;;\nconsole.log(str.split(\/\\w+\/g));\/\/(5)\u00a0[&quot;&quot;, &quot;  | &quot;, &quot; , &quot;, &quot; &amp; &quot;, &quot;&quot;]\n\/** *\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/*P86-\u6b63\u5219-\u521b\u5efa\u6b63\u5219\u8868\u8fbe\u5f0f*\/ \/\/\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u7528\u6765\u8868\u8fbe\u5b57\u7b26\u4e32\u89c4\u5219\u548c\u6a21\u5f0f\u7684 \/\/\u7528\u5b83\u5224\u65ad\u67d0\u4e9b\u5b57\u7b26\u4e32\u662f\u5426\u7b26 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/918"}],"collection":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/comments?post=918"}],"version-history":[{"count":1,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/918\/revisions"}],"predecessor-version":[{"id":919,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/posts\/918\/revisions\/919"}],"wp:attachment":[{"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/media?parent=918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/categories?post=918"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.henrycome.com\/wordpress\/wp-json\/wp\/v2\/tags?post=918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}