{"id":166252,"date":"2024-05-08T15:32:52","date_gmt":"2024-05-08T07:32:52","guid":{"rendered":""},"modified":"2024-05-08T15:32:56","modified_gmt":"2024-05-08T07:32:56","slug":"javascript%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/166252.html","title":{"rendered":"javascript\u6b63\u5219\u8868\u8fbe"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26233322\/a9b5e5d3-f5a2-481f-9a4f-111d00ba5036.webp\" alt=\"javascript\u6b63\u5219\u8868\u8fbe\" \/><\/p>\n<p><p>JavaScript\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u6587\u672c\u5904\u7406\u5de5\u5177\uff0c\u5b83\u7528\u4e8e\u5b57\u7b26\u4e32\u7684\u641c\u7d22\u3001\u9a8c\u8bc1\u548c\u66ff\u6362\u3002<strong>\u6838\u5fc3\u89c2\u70b9\u5305\u62ec\uff1a\u6a21\u5f0f\u5339\u914d\u3001\u641c\u7d22\u66ff\u6362\u3001\u8868\u5355\u9a8c\u8bc1\u3001\u5206\u7ec4\u6355\u83b7\u3001\u8d2a\u5a6a\u4e0e\u975e\u8d2a\u5a6a\u5339\u914d\u3001\u524d\u77bb\u65ad\u8a00<\/strong>\u7b49\u5173\u952e\u529f\u80fd\u3002\u5176\u4e2d\uff0c<strong>\u6a21\u5f0f\u5339\u914d<\/strong>\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u57fa\u7840\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u5b9a\u4e49\u4e00\u4e2a\u641c\u7d22\u6a21\u5f0f\uff0c\u8be5\u6a21\u5f0f\u7528\u4e8e\u5339\u914d\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u5b9a\u5e8f\u5217\u3002\u8fd9\u79cd\u80fd\u529b\u4f7f\u5f97\u8fdb\u884c\u590d\u6742\u6587\u672c\u5206\u6790\u548c\u5904\u7406\u6210\u4e3a\u53ef\u80fd\uff0c\u4ece\u800c\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u5f00\u53d1\u6548\u7387\u548c\u7075\u6d3b\u6027\u3002<\/p>\n<\/p>\n<p><p>\u5728\u6df1\u5165\u4ecb\u7ecd\u6838\u5fc3\u89c2\u70b9\u4e4b\u524d\uff0c\u6211\u4eec\u5c06\u4ece\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u57fa\u672c\u7ec4\u6210\u8981\u7d20\u5165\u624b\uff0c\u9010\u6b65\u63a2\u8ba8\u5176\u5f3a\u5927\u529f\u80fd\uff0c\u5e76\u7ed9\u51fa\u5b9e\u9645\u5e94\u7528\u793a\u4f8b\uff0c\u4ee5\u5e2e\u52a9\u7406\u89e3\u5982\u4f55\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u9ad8\u6548\u5730\u4f7f\u7528JavaScript\u6b63\u5219\u8868\u8fbe\u5f0f\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u57fa\u7840<\/h2>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u7531\u5b57\u7b26\u548c\u7279\u6b8a\u7b26\u53f7\u7ec4\u6210\uff0c\u7528\u4e8e\u5b9a\u4e49\u641c\u7d22\u6216\u5339\u914d\u5b57\u7b26\u4e32\u7684\u6a21\u5f0f\u3002\u5728JavaScript\u4e2d\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u521b\u5efa\uff1a\u4e00\u662f\u4f7f\u7528\u5b57\u9762\u91cf\uff0c\u4e8c\u662f\u4f7f\u7528<code>RegExp<\/code>\u6784\u9020\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u5b57\u9762\u91cf\u4e0e\u6784\u9020\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u5b57\u9762\u91cf\u65b9\u5f0f\u662f\u6700\u5e38\u7528\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5b9a\u4e49\u65b9\u5f0f\uff0c\u4f8b\u5982<code>\/abc\/<\/code>\u3002\u800c\u4f7f\u7528<code>RegExp<\/code>\u6784\u9020\u51fd\u6570\uff0c\u53ef\u4ee5\u52a8\u6001\u5730\u521b\u5efa\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u5982<code>new RegExp(&quot;abc&quot;)<\/code>\u3002\u4e24\u8005\u5728\u529f\u80fd\u4e0a\u5b8c\u5168\u76f8\u7b49\uff0c\u4f46\u6784\u9020\u51fd\u6570\u7684\u4f7f\u7528\u573a\u666f\u66f4\u4e3a\u7075\u6d3b\uff0c\u5c24\u5176\u5728\u5904\u7406\u53d8\u91cf\u548c\u52a8\u6001\u751f\u6210\u6b63\u5219\u8868\u8fbe\u5f0f\u65f6\u66f4\u663e\u4f18\u52bf\u3002<\/p>\n<\/p>\n<p><h3>\u6a21\u5f0f\u5339\u914d<\/h3>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u6838\u5fc3\u662f\u6a21\u5f0f\u5339\u914d\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u5b9a\u4e49\u590d\u6742\u7684\u641c\u7d22\u6a21\u5f0f\u3002\u4f8b\u5982\uff0c\u8981\u5339\u914d\u4e00\u4e2a\u624b\u673a\u53f7\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u6a21\u5f0f<code>\/\\d{11}\/<\/code>\uff0c\u8fd9\u544a\u8bc9JavaScript\u67e5\u627e\u753111\u4e2a\u6570\u5b57\u7ec4\u6210\u7684\u5e8f\u5217\u3002\u901a\u8fc7\u6a21\u5f0f\u5339\u914d\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u4ece\u5927\u91cf\u6587\u672c\u4e2d\u627e\u5230\u7b26\u5408\u7279\u5b9a\u89c4\u5219\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u5e38\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u7b26\u53f7<\/h2>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5a01\u529b\u5728\u4e8e\u5176\u4f7f\u7528\u7684\u7279\u6b8a\u7b26\u53f7\uff0c\u8fd9\u4e9b\u7b26\u53f7\u5141\u8bb8\u5b9a\u4e49\u975e\u5e38\u7cbe\u786e\u7684\u641c\u7d22\u6a21\u5f0f\u3002\u5176\u4e2d\u5305\u62ec\u91cf\u8bcd\u3001\u5b57\u7b26\u7c7b\u3001\u5206\u7ec4\u548c\u5b9a\u4f4d\u7b26\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u91cf\u8bcd<\/h3>\n<\/p>\n<p><p>\u91cf\u8bcd\u7528\u4e8e\u6307\u5b9a\u4e00\u4e2a\u5143\u7d20\u5fc5\u987b\u51fa\u73b0\u7684\u6b21\u6570\uff0c\u5e38\u89c1\u7684\u91cf\u8bcd\u5305\u62ec<code>+<\/code>\uff08\u4e00\u6b21\u6216\u591a\u6b21\uff09\u3001<code>*<\/code>\uff08\u96f6\u6b21\u6216\u591a\u6b21\uff09\u548c<code>?<\/code>\uff08\u96f6\u6b21\u6216\u4e00\u6b21\uff09\u3002\u4f8b\u5982\uff0c<code>\/a+\/<\/code>\u5339\u914d\u4e00\u4e2a\u6216\u591a\u4e2a\u8fde\u7eed\u7684&quot;a&quot;\u5b57\u7b26\u3002<\/p>\n<\/p>\n<p><h3>\u5b57\u7b26\u7c7b<\/h3>\n<\/p>\n<p><p>\u5b57\u7b26\u7c7b\u5141\u8bb8\u5339\u914d\u6307\u5b9a\u96c6\u5408\u5185\u7684\u4efb\u610f\u5b57\u7b26\u3002\u4f8b\u5982\uff0c<code>\/[abc]\/<\/code>\u53ef\u4ee5\u5339\u914d&quot;a&quot;\u3001&quot;b&quot;\u3001\u6216&quot;c&quot;\u3002\u4f7f\u7528\u5b57\u7b26\u7c7b\u53ef\u4ee5\u65b9\u4fbf\u5730\u5339\u914d\u591a\u4e2a\u53ef\u80fd\u7684\u5b57\u7b26\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u641c\u7d22\u548c\u66ff\u6362<\/h2>\n<\/p>\n<p><p>\u5728JavaScript\u4e2d\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u5e38\u7528\u4e8e\u5b57\u7b26\u4e32\u641c\u7d22\u548c\u66ff\u6362\u64cd\u4f5c\u3002<code>String<\/code>\u5bf9\u8c61\u63d0\u4f9b\u4e86<code>match<\/code>\u3001<code>replace<\/code>\u548c<code>search<\/code>\u7b49\u65b9\u6cd5\uff0c\u4f7f\u5f97\u5229\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u6587\u672c\u5904\u7406\u53d8\u5f97\u7b80\u5355\u9ad8\u6548\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528<code>match<\/code>\u8fdb\u884c\u6a21\u5f0f\u5339\u914d<\/h3>\n<\/p>\n<p><p><code>match<\/code>\u65b9\u6cd5\u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u4e2d\u641c\u7d22\u5339\u914d\u7684\u5b50\u4e32\u3002\u8fd4\u56de\u4e00\u4e2a\u6570\u7ec4\uff0c\u5305\u542b\u4e86\u6240\u6709\u5339\u914d\u7684\u7ed3\u679c\u3002\u5982\u679c\u6ca1\u6709\u627e\u5230\u5339\u914d\uff0c\u5219\u8fd4\u56de<code>null<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528<code>replace<\/code>\u8fdb\u884c\u66ff\u6362<\/h3>\n<\/p>\n<p><p><code>replace<\/code>\u65b9\u6cd5\u4e0d\u4ec5\u53ef\u4ee5\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u6587\u672c\uff0c\u8fd8\u53ef\u4ee5\u63a5\u53d7\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u63d0\u4f9b\u66f4\u52a0\u7075\u6d3b\u7684\u66ff\u6362\u7b56\u7565\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u7528\u6765\u683c\u5f0f\u5316\u6587\u672c\u6216\u8005\u66f4\u6539\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u5b9a\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u8868\u5355\u9a8c\u8bc1<\/h2>\n<\/p>\n<p><p>\u5728Web\u5f00\u53d1\u4e2d\uff0c\u5bf9\u7528\u6237\u8f93\u5165\u7684\u9a8c\u8bc1\u662f\u4e00\u9879\u57fa\u672c\u4e14\u91cd\u8981\u7684\u9700\u6c42\u3002\u6b63\u5219\u8868\u8fbe\u5f0f\u5728\u8868\u5355\u9a8c\u8bc1\u4e2d\u626e\u6f14\u7740\u5173\u952e\u89d2\u8272\uff0c\u5b83\u53ef\u4ee5\u786e\u4fdd\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u7b26\u5408\u7279\u5b9a\u7684\u683c\u5f0f\u8981\u6c42\uff0c\u6bd4\u5982\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3001\u624b\u673a\u53f7\u7801\u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u7535\u5b50\u90ae\u4ef6\u9a8c\u8bc1<\/h3>\n<\/p>\n<p><p>\u7535\u5b50\u90ae\u4ef6\u7684\u9a8c\u8bc1\u53ef\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f<code>\/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$\/<\/code>\u6765\u5b9e\u73b0\uff0c\u8fd9\u4e2a\u6a21\u5f0f\u786e\u4fdd\u4e86\u7535\u5b50\u90ae\u4ef6\u7684\u57fa\u672c\u683c\u5f0f\u6b63\u786e\u6027\u3002\u901a\u8fc7\u5728\u8868\u5355\u7684\u63d0\u4ea4\u4e8b\u4ef6\u4e2d\u5e94\u7528\u6b64\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u53ef\u4ee5\u5728\u6570\u636e\u88ab\u53d1\u9001\u5230\u670d\u52a1\u5668\u4e4b\u524d\u786e\u4fdd\u7528\u6237\u8f93\u5165\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u683c\u5f0f\u6b63\u786e\u3002<\/p>\n<\/p>\n<p><h3>\u624b\u673a\u53f7\u7801\u9a8c\u8bc1<\/h3>\n<\/p>\n<p><p>\u7c7b\u4f3c\u5730\uff0c\u5bf9\u624b\u673a\u53f7\u7801\u7684\u9a8c\u8bc1\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<code>\/\\d{11}\/<\/code>\uff0c\u4ee5\u786e\u4fdd\u8f93\u5165\u7684\u662f11\u4f4d\u6570\u5b57\u3002\u8fd9\u662f\u5bf9\u4e2d\u56fd\u5927\u9646\u624b\u673a\u53f7\u7801\u683c\u5f0f\u7684\u7b80\u5316\u9a8c\u8bc1\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u60c5\u51b5\uff0c\u5e2e\u52a9\u786e\u4fdd\u7528\u6237\u8f93\u5165\u4e86\u6709\u6548\u7684\u624b\u673a\u53f7\u7801\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u8fdb\u9636\u6280\u5de7<\/h2>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b66\u4e60\u662f\u4e00\u4e2a\u6df1\u4e0d\u89c1\u5e95\u7684\u8fc7\u7a0b\uff0c\u4f46\u638c\u63e1\u4e00\u4e9b\u8fdb\u9636\u6280\u5de7\u53ef\u4ee5\u8ba9\u4f60\u5728\u4f7f\u7528\u65f6\u66f4\u52a0\u5f97\u5fc3\u5e94\u624b\u3002<\/p>\n<\/p>\n<p><h3>\u5206\u7ec4\u6355\u83b7<\/h3>\n<\/p>\n<p><p>\u5206\u7ec4\u6355\u83b7\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\u975e\u5e38\u5f3a\u5927\u7684\u529f\u80fd\u4e4b\u4e00\uff0c\u5b83\u5141\u8bb8\u5c06\u5339\u914d\u7684\u90e8\u5206\u5206\u7ec4\u5e76\u8fdb\u884c\u4e2a\u522b\u5904\u7406\u3002\u901a\u8fc7\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u62ec\u53f7<code>()<\/code>\uff0c\u53ef\u4ee5\u521b\u5efa\u6355\u83b7\u7ec4\uff0c\u4e4b\u540e\u53ef\u4ee5\u5355\u72ec\u83b7\u53d6\u6216\u66ff\u6362\u8fd9\u4e9b\u7ec4\u4e2d\u7684\u5185\u5bb9\u3002<\/p>\n<\/p>\n<p><h3>\u8d2a\u5a6a\u4e0e\u975e\u8d2a\u5a6a\u5339\u914d<\/h3>\n<\/p>\n<p><p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u91cf\u8bcd\uff08\u5982<code>+<\/code>\u3001<code>*<\/code>\uff09\u662f\u8d2a\u5a6a\u7684\uff0c\u610f\u5473\u7740\u5b83\u4eec\u4f1a\u5c3d\u53ef\u80fd\u591a\u5730\u5339\u914d\u5b57\u7b26\u3002\u5728\u4e00\u4e9b\u60c5\u51b5\u4e0b\uff0c\u8fd9\u53ef\u80fd\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\u7ed3\u679c\u3002\u901a\u8fc7\u5728\u91cf\u8bcd\u540e\u9762\u6dfb\u52a0<code>?<\/code>\uff0c\u53ef\u4ee5\u5b9e\u73b0\u975e\u8d2a\u5a6a\u5339\u914d\uff0c\u5373\u5c3d\u53ef\u80fd\u5c11\u5730\u5339\u914d\u5b57\u7b26\u3002<\/p>\n<\/p>\n<p><h2>\u7ed3\u8bed<\/h2>\n<\/p>\n<p><p>\u901a\u8fc7\u5168\u9762\u5730\u4e86\u89e3\u548c\u5b66\u4e60JavaScript\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5404\u4e2a\u65b9\u9762\uff0c\u4ece\u57fa\u7840\u8bed\u6cd5\u5230\u8fdb\u9636\u6280\u5de7\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u6587\u672c\u5904\u7406\u7684\u6548\u7387\u548c\u51c6\u786e\u6027\u3002\u6b63\u5219\u8868\u8fbe\u5f0f\u867d\u7136\u5728\u521d\u5b66\u65f6\u53ef\u80fd\u770b\u8d77\u6765\u590d\u6742\u548c\u96be\u4ee5\u7406\u89e3\uff0c\u4f46\u968f\u7740\u5b9e\u8df5\u7684\u79ef\u7d2f\uff0c\u5b83\u5c06\u6210\u4e3a\u6bcf\u4e2aJavaScript\u5f00\u53d1\u8005\u5de5\u5177\u7bb1\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u4f7f\u7528JavaScript\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u5b57\u7b26\u4e32\u5339\u914d\uff1f<\/strong><br \/>\n\u5728JavaScript\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u8fdb\u884c\u5b57\u7b26\u4e32\u5339\u914d\u3002\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u8c61\uff0c\u5e76\u4f7f\u7528\u5176\u4e2d\u7684\u65b9\u6cd5\uff0c\u5982test()\u548cmatch()\u6765\u8fdb\u884c\u5339\u914d\u64cd\u4f5c\u3002test()\u65b9\u6cd5\u7528\u4e8e\u786e\u5b9a\u4e00\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u4e0e\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\uff0c\u800cmatch()\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5339\u914d\u7ed3\u679c\u7684\u6570\u7ec4\u3002\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5404\u79cd\u5143\u5b57\u7b26\u548c\u4fee\u9970\u7b26\uff0c\u53ef\u4ee5\u5b9e\u73b0\u66f4\u52a0\u7075\u6d3b\u548c\u7cbe\u786e\u7684\u5339\u914d\u3002<\/p>\n<p><strong>2. JavaScript\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u7684\u5e38\u7528\u5143\u5b57\u7b26\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\nJavaScript\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u6709\u8bb8\u591a\u5e38\u7528\u7684\u5143\u5b57\u7b26\uff0c\u7528\u4e8e\u5339\u914d\u4e0d\u540c\u7c7b\u578b\u7684\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\\d\uff1a\u5339\u914d\u4efb\u4f55\u4e00\u4e2a\u6570\u5b57\u5b57\u7b26\uff1b<\/li>\n<li>\\w\uff1a\u5339\u914d\u4efb\u4f55\u4e00\u4e2a\u5b57\u6bcd\u3001\u6570\u5b57\u6216\u4e0b\u5212\u7ebf\u5b57\u7b26\uff1b<\/li>\n<li>\\s\uff1a\u5339\u914d\u4e00\u4e2a\u7a7a\u767d\u5b57\u7b26\uff1b<\/li>\n<li>.\uff1a\u5339\u914d\u4efb\u4f55\u4e00\u4e2a\u5b57\u7b26\uff0c\u9664\u4e86\u6362\u884c\u7b26\uff1b<\/li>\n<li>^\uff1a\u5339\u914d\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\uff1b<\/li>\n<li>$\uff1a\u5339\u914d\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\u4f4d\u7f6e\uff1b<\/li>\n<li>[&#8230;]\uff1a\u5339\u914d\u65b9\u62ec\u53f7\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u4e9b\u5143\u5b57\u7b26\u7684\u4f7f\u7528\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u7f16\u5199\uff0c\u4ece\u800c\u66f4\u52a0\u65b9\u4fbf\u5730\u5b9e\u73b0\u5b57\u7b26\u4e32\u5339\u914d\u64cd\u4f5c\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u5728JavaScript\u4e2d\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u5b57\u7b26\u4e32\u66ff\u6362\uff1f<\/strong><br \/>\n\u9664\u4e86\u5339\u914d\u64cd\u4f5c\uff0cJavaScript\u6b63\u5219\u8868\u8fbe\u5f0f\u8fd8\u53ef\u4ee5\u7528\u4e8e\u5b57\u7b26\u4e32\u66ff\u6362\u3002\u901a\u8fc7\u4f7f\u7528replace()\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5c06\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u5230\u7684\u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u6307\u5b9a\u7684\u5185\u5bb9\u3002replace()\u65b9\u6cd5\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff1a\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u8981\u88ab\u66ff\u6362\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u66ff\u6362\u7684\u5b57\u7b26\u4e32\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528\u7279\u6b8a\u7684\u66ff\u6362\u6a21\u5f0f\uff0c\u5982$1\u3001$2\u7b49\uff0c\u6765\u5f15\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u7684\u5206\u7ec4\u6355\u83b7\u7ed3\u679c\u3002\u8fd9\u6837\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u7075\u6d3b\u7684\u5b57\u7b26\u4e32\u66ff\u6362\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"JavaScript\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u6587\u672c\u5904\u7406\u5de5\u5177\uff0c\u5b83\u7528\u4e8e\u5b57\u7b26\u4e32\u7684\u641c\u7d22\u3001\u9a8c\u8bc1\u548c\u66ff\u6362\u3002\u6838\u5fc3\u89c2\u70b9\u5305\u62ec\uff1a\u6a21\u5f0f\u5339 [&hellip;]","protected":false},"author":3,"featured_media":166256,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/166252"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=166252"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/166252\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/166256"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=166252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=166252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=166252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}