{"id":322,"date":"2009-04-16T21:33:00","date_gmt":"2009-04-16T01:33:00","guid":{"rendered":""},"modified":"2009-04-16T21:33:00","modified_gmt":"2009-04-16T01:33:00","slug":"","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/322.html","title":{"rendered":"JavaScript \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u8868"},"content":{"rendered":"<p><html><head><meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/><title>JavaScript \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u8868<\/title><\/head><body><\/p>\n<h1 style=\"display:none\">JavaScript \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u8868<\/h1>\n<div>\n<table style=\"border-collapse: collapse\" border=\"1\" cellspacing=\"1\" bordercolor=\"#808080\">\n<tbody>\n<tr>\n<td width=\"72\">\n<p align=\"center\"><strong>\u5b57\u7b26<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"center\"><strong>\u63cf\u8ff0<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><strong>\\<\/strong><\/td>\n<td>\u6807\u8bb0\u4e0b\u4e00\u4e2a\u5b57\u7b26\u662f\u7279\u6b8a\u5b57\u7b26\u6216\u6587\u5b57\u3002\u4f8b\u5982\uff0c&quot;n&quot; \u548c\u5b57\u7b26 &quot;n&quot; \u5339\u914d\u3002&quot;\\n&quot; \u5219\u548c\u6362\u884c\u5b57\u7b26\u5339\u914d\u3002\u5e8f\u5217 &quot;\\\\&quot; \u548c &quot;\\&quot; \u5339\u914d\uff0c\u800c &quot;\\(&quot; \u5219\u548c &quot;(&quot; \u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>^<\/strong><\/td>\n<td>\u5339\u914d\u8f93\u5165\u7684\u5f00\u5934\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>$<\/strong><\/td>\n<td>\u5339\u914d\u8f93\u5165\u7684\u672b\u5c3e\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>*<\/strong><\/td>\n<td>\u5339\u914d\u524d\u4e00\u4e2a\u5b57\u7b26\u96f6\u6216\u591a\u6b21\u3002\u4f8b\u5982\uff0c&quot;zo*&quot; \u4e0e &quot;z&quot; \u6216 &quot;zoo&quot; \u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>+<\/strong><\/td>\n<td>\u5339\u914d\u524d\u4e00\u4e2a\u5b57\u7b26\u4e00\u6b21\u6216\u591a\u6b21\u3002\u4f8b\u5982\uff0c&quot;zo+&quot; \u4e0e &quot;zoo&quot; \u5339\u914d\uff0c\u4f46\u548c &quot;z&quot; \u4e0d\u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>?<\/strong><\/td>\n<td>\u5339\u914d\u524d\u4e00\u4e2a\u5b57\u7b26\u96f6\u6216\u4e00\u6b21\u3002\u4f8b\u5982\uff0c&quot;a?ve?&quot; \u548c &quot;never&quot; \u4e2d\u7684 &quot;ve&quot; \u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>.<\/strong><\/td>\n<td>\u5339\u914d\u9664\u6362\u884c\u5b57\u7b26\u5916\u7684\u4efb\u4f55\u5355\u4e2a\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>(<\/strong><em>pattern<\/em><strong>)<\/strong><\/td>\n<td>\u5339\u914d <em>pattern<\/em> \u5e76\u8bb0\u4f4f\u8be5\u5339\u914d\u3002\u5339\u914d\u4e0a\u7684\u5b50\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 Item <strong>[0]&#8230;[n]<\/strong>\uff0c\u6765\u4ece\u751f\u6210\u7684 <strong>Matches<\/strong> \u96c6\u5408\u4e2d\u53d6\u56de\u3002\u8981\u5339\u914d\u5706\u62ec\u53f7\u5b57\u7b26 ( )\uff0c\u5219\u9700\u4f7f\u7528 &quot;\\(&quot; \u6216 &quot;\\)&quot;\u3002<\/td>\n<\/tr>\n<tr>\n<td><em>x<\/em><strong>|<\/strong><em>y<\/em><\/td>\n<td>\u5339\u914d <em>x<\/em> \u6216 <ii><\/ii>y\u3002\u4f8b\u5982\uff0c&quot;z|food&quot; \u548c &quot;z&quot; \u6216 &quot;food&quot; \u5339\u914d\u3002&quot;(z|f)ood&quot; \u5339\u914d &quot;zoo&quot; \u6216 &quot;food&quot;\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>{<\/strong><em>n<\/em><strong>}<\/strong><\/td>\n<td><em>n<\/em> \u662f\u975e\u8d1f\u6574\u6570\u3002\u5171\u5339\u914d n \u6b21\u3002\u4f8b\u5982\uff0c&quot;o{2}&quot; \u548c &quot;Bob&quot; \u4e2d\u7684 &quot;o&quot; \u4e0d\u5339\u914d\uff0c\u4f46\u548c &quot;foooood&quot; \u4e2d\u7684\u524d\u4e24\u4e2a o \u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>{<\/strong><em>n<strong>,}<\/strong><\/em><\/td>\n<td>n \u662f\u4e00\u4e2a\u975e\u8d1f\u6574\u6570\u3002\u81f3\u5c11\u5339\u914d n \u6b21\u3002\u4f8b\u5982\uff0c&quot;o{2,}&quot; \u548c &quot;Bob&quot; \u4e2d\u7684 &quot;o&quot; \u4e0d\u5339\u914d\uff0c\u4f46\u548c &quot;foooood&quot; \u4e2d\u7684\u6240\u6709 o \u5339\u914d\u3002&quot;o{1,}&quot; \u4e0e &quot;o+&quot; \u7b49\u6548\u3002&quot;o{0,}&quot; \u548c &quot;o*&quot; \u7b49\u6548\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>{<\/strong>n<strong>,<\/strong><em>m<\/em><strong>}<\/strong><\/td>\n<td>m \u548c n \u662f\u975e\u8d1f\u6574\u6570\u3002\u81f3\u5c11\u5339\u914d n \u6b21\u800c\u81f3\u591a\u5339\u914d m \u6b21\u3002\u4f8b\u5982\uff0c&quot;o{1,3}&quot; \u548c &quot;fooooood&quot; \u4e2d\u7684\u524d\u4e09\u4e2a o \u5339\u914d\u3002&quot;o{0,1}&quot; \u548c &quot;o?&quot; \u7b49\u6548\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>[<\/strong><ii><\/ii> xyz<strong>]<\/strong><\/td>\n<td>\u5b57\u7b26\u96c6\u5408\u3002\u5339\u914d\u62ec\u53f7\u5185\u7684\u4efb\u4e00\u5b57\u7b26\u3002\u4f8b\u5982\uff0c&quot;[abc]&quot; \u548c &quot;plain&quot; \u4e2d\u7684 &quot;a&quot; \u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>[^<\/strong>xyz <strong>]<\/strong><\/td>\n<td>\u5426\u5b9a\u5b57\u7b26\u96c6\u5408\u3002\u5339\u914d\u975e\u62ec\u53f7\u5185\u7684\u4efb\u4f55\u5b57\u7b26\u3002\u4f8b\u5982\uff0c&quot;[^abc]&quot; \u548c &quot;plain&quot; \u4e2d\u7684 &quot;p&quot; \u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>[<\/strong><em>a-z<\/em><strong>]<\/strong><\/td>\n<td>\u5b57\u7b26\u8303\u56f4\u3002\u548c\u6307\u5b9a\u8303\u56f4\u5185\u7684\u4efb\u4e00\u5b57\u7b26\u5339\u914d\u3002\u4f8b\u5982\uff0c&quot;[a-z]&quot; \u5339\u914d &quot;a&quot; \u5230 &quot;z&quot;\u8303\u56f4\u5185\u7684\u4efb\u4e00\u5c0f\u5199\u7684\u5b57\u6bcd\u8868\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>[^<\/strong><em>m-z<\/em><strong>]<\/strong><\/td>\n<td>\u5426\u5b9a\u5b57\u7b26\u8303\u56f4\u3002\u5339\u914d\u4e0d\u5728\u6307\u5b9a\u8303\u56f4\u5185\u7684\u4efb\u4f55\u5b57\u7b26\u3002\u4f8b\u5982\uff0c&quot;[m-z]&quot; \u5339\u914d\u4e0d\u5728 &quot;m&quot; \u5230 &quot;z&quot;\u8303\u56f4\u5185\u7684\u4efb\u4f55\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\b<\/strong><\/td>\n<td>\u5339\u914d\u5b57\u7684\u8fb9\u754c\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5728\u5b57\u548c\u7a7a\u683c\u4e4b\u95f4\u7684\u4f4d\u7f6e\u3002\u4f8b\u5982\uff0c&quot;er\\b&quot; \u548c &quot;never&quot; \u4e2d\u7684 &quot;er&quot; \u5339\u914d\uff0c\u4f46\u548c &quot;verb&quot; \u4e2d\u7684 &quot;er&quot; \u4e0d\u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\B<\/strong><\/td>\n<td>\u5339\u914d\u975e\u5b57\u8fb9\u754c\u3002&quot;ea*r\\B&quot; \u548c &quot;never early&quot; \u4e2d\u7684 &quot;ear&quot; \u5339\u914d\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\d<\/strong><\/td>\n<td>\u5339\u914d\u6570\u5b57\u5b57\u7b26\u3002\u7b49\u4ef7\u4e8e [0-9]\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\D<\/strong><\/td>\n<td>\u5339\u914d\u975e\u6570\u5b57\u5b57\u7b26\u3002\u7b49\u4ef7\u4e8e [^0-9]\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\f<\/strong><\/td>\n<td>\u5339\u914d\u6362\u9875\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\n<\/strong><\/td>\n<td>\u5339\u914d\u6362\u884c\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\r<\/strong><\/td>\n<td>\u5339\u914d\u56de\u8f66\u7b26\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\s<\/strong><\/td>\n<td>\u5339\u914d\u4efb\u4f55\u7a7a\u767d\uff0c\u5305\u62ec\u7a7a\u683c\u3001\u5236\u8868\u3001\u6362\u9875\u7b49\u3002\u4e0e &quot;[ \\f\\n\\r\\t\\v]&quot; \u7b49\u6548\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\S<\/strong><\/td>\n<td>\u5339\u914d\u4efb\u4f55\u975e\u7a7a\u767d\u5b57\u7b26\u3002\u4e0e &quot;[^ \\f\\n\\r\\t\\v]&quot; \u7b49\u6548\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\t<\/strong><\/td>\n<td>\u5339\u914d\u5236\u8868\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\v<\/strong><\/td>\n<td>\u5339\u914d\u5782\u76f4\u5236\u8868\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\w<\/strong><\/td>\n<td>\u5339\u914d\u5305\u62ec\u4e0b\u5212\u7ebf\u5728\u5185\u7684\u4efb\u4f55\u5b57\u5b57\u7b26\u3002\u4e0e &quot;[A-Za-z0-9_]&quot; \u7b49\u6548\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\W<\/strong><\/td>\n<td>\u5339\u914d\u4efb\u4f55\u975e\u5b57\u5b57\u7b26\u3002\u4e0e &quot;[^A-Za-z0-9_]&quot; \u7b49\u6548\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\<\/strong><em>num<\/em><\/td>\n<td>\u5339\u914d <em>num<\/em>\uff0c\u5176\u4e2d <em>num<\/em> \u662f\u4e00\u4e2a\u6b63\u6574\u6570\u3002\u8fd4\u56de\u8bb0\u4f4f\u7684\u5339\u914d\u7684\u5f15\u7528\u3002\u4f8b\u5982\uff0c&quot;(.)\\1&quot; \u5339\u914d\u4e24\u4e2a\u8fde\u7eed\u7684\u540c\u4e00\u5b57\u7b26\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\<\/strong><em>n<\/em><\/td>\n<td>\u5339\u914d n\uff0c\u5176\u4e2d n \u662f\u516b\u8fdb\u5236\u6362\u7801\u503c\u3002\u516b\u8fdb\u5236\u6362\u7801\u503c\u5fc5\u987b\u662f 1\u30012\u3001\u6216 3 \u4f4d\u957f\u3002\u4f8b\u5982\uff0c&quot;\\11&quot; \u548c &quot;\\011&quot; \u90fd\u5339\u914d\u5236\u8868\u5b57\u7b26\u3002&quot;\\0011&quot; \u548c &quot;\\001&quot; &amp; &quot;1&quot; \u662f\u7b49\u6548\u7684\u3002\u516b\u8fdb\u5236\u6362\u7801\u503c\u5fc5\u987b\u4e0d\u8d85\u8fc7 256\u3002\u5982\u679c\u8d85\u8fc7\u4e86\uff0c\u5219\u53ea\u6709\u524d\u4e24\u4f4d\u7ec4\u6210\u8868\u8fbe\u5f0f\u3002\u5141\u8bb8\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528 ASCII \u7801\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>\\x<\/strong>n<\/td>\n<td>\u5339\u914d n\uff0c\u5176\u4e2d <em>n<\/em> \u662f\u5341\u516d\u8fdb\u5236\u6362\u7801\u503c\u3002\u5341\u516d\u8fdb\u5236\u6362\u7801\u503c\u5fc5\u987b\u6b63\u597d\u662f\u4e24\u4f4d\u957f\u3002\u4f8b\u5982\uff0c&quot;\\x41&quot; \u4e0e &quot;A&quot; \u5339\u914d\u3002&quot;\\x041&quot; \u548c &quot;\\x04&quot; &amp; &quot;1&quot; \u662f\u7b49\u6548\u7684\u3002\u5141\u8bb8\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528 ASCII \u7801\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u8868 JavaScript \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u8868 \u5b57\u7b26 \u63cf\u8ff0 \\ \u6807\u8bb0\u4e0b\u4e00\u4e2a\u5b57\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":[6],"tags":[],"class_list":["post-322","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":0,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}