{"id":49803,"date":"2024-12-03T17:33:06","date_gmt":"2024-12-03T09:33:06","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49803\/"},"modified":"2024-12-03T17:33:06","modified_gmt":"2024-12-03T09:33:06","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e5%8c%b9%e9%85%8d%e6%81%b0%e5%a5%bd%e4%b8%89%e4%b8%aa%e8%bf%9e%e7%bb%ad%e6%95%b0%e5%ad%97%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49803\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff1f<\/h1>\n<p>\u4eb2\u7231\u7684\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5982\u679c\u4f60\u70b9\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf4\u660e\u4f60\u5bf9\u300a\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff1f\u300b\u5f88\u611f\u5174\u8da3\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u7ed9\u5927\u5bb6\u8be6\u7ec6\u89e3\u6790\u4e00\u4e0b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u6240\u6709\u8ba4\u771f\u8bfb\u5b8c\u7684\u7ae5\u978b\u4eec\uff0c\u90fd\u6709\u5b9e\u8d28\u6027\u7684\u63d0\u9ad8\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241104\/17306919466728436a4168f.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6b63\u5219\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57<\/strong><\/p>\n<p>\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff0c\u65e2\u4e0d\u80fd\u5c11\u4e8e\u4e09\u4e2a\u4e5f\u4e0d\u80fd\u591a\u4e8e\u4e09\u4e2a\uff1f<\/p>\n<p>\u539f\u5148\u7684\u6b63\u5219\u8868\u8fbe\u5f0f &#8220;[^0-9]*[0-9]{3}[^0-9]*&#8221; \u867d\u7136\u53ef\u4ee5\u5339\u914d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff0c\u4f46\u5b83\u5ffd\u7565\u4e86\u5f00\u5934\u6216\u7ed3\u5c3e\u53ef\u80fd\u5b58\u5728\u7684\u975e\u6570\u5b57\u5b57\u7b26\u3002<\/p>\n<p>\u4fee\u6539\u540e\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre>(?&amp;lt;!\\d)(\\d{3})(?!\\d)<\/pre>\n<ul>\n<li>(?&lt;!d)\uff1a\u8d1f\u5411\u524d\u77bb\u65ad\u8a00\uff0c\u786e\u4fdd\u5339\u914d\u7684\u6570\u5b57\u5e8f\u5217\u4e4b\u524d\u6ca1\u6709\u6570\u5b57\u5b57\u7b26\u3002<\/li>\n<li>(d{3})\uff1a\u6355\u83b7\u7ec4\uff0c\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\u3002<\/li>\n<li>(?!d)\uff1a\u8d1f\u5411\u540e\u77bb\u65ad\u8a00\uff0c\u786e\u4fdd\u5339\u914d\u7684\u6570\u5b57\u5e8f\u5217\u4e4b\u540e\u6ca1\u6709\u6570\u5b57\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<p><strong>python \u793a\u4f8b<\/strong><\/p>\n<pre>import re\n\ndata = [\n    '123',\n    '123u',\n    'u123',\n    'x123y',\n    '1234',\n    'x1234y',\n    '12',\n    '123y456',\n]\n\nfor s in data:\n    print(re.findall(r'(?&amp;lt;!\\d)(\\d{3})(?!\\d)', s))<\/pre>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre>['123']\n['123']\n['123']\n['123']\n[]\n[]\n[]\n['123', '456']<\/pre>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff1f \u4eb2\u7231\u7684\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5982\u679c\u4f60\u70b9\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf4\u660e\u4f60\u5bf9\u300a\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff1f\u300b\u5f88\u611f\u5174\u8da3\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u7ed9\u5927\u5bb6\u8be6\u7ec6\u89e3\u6790\u4e00\u4e0b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u6240\u6709\u8ba4\u771f\u8bfb\u5b8c\u7684\u7ae5\u978b\u4eec\uff0c\u90fd\u6709\u5b9e\u8d28\u6027\u7684\u63d0\u9ad8\u3002 \u6b63\u5219\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57 \u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff0c\u65e2\u4e0d\u80fd\u5c11\u4e8e\u4e09\u4e2a\u4e5f\u4e0d\u80fd\u591a\u4e8e\u4e09\u4e2a\uff1f \u539f\u5148\u7684\u6b63\u5219\u8868\u8fbe\u5f0f &#8220;[^0-9]*[0-9]{3}[^0-9]*&#8221; \u867d\u7136\u53ef\u4ee5\u5339\u914d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\uff0c\u4f46\u5b83\u5ffd\u7565\u4e86\u5f00\u5934\u6216\u7ed3\u5c3e\u53ef\u80fd\u5b58\u5728\u7684\u975e\u6570\u5b57\u5b57\u7b26\u3002 \u4fee\u6539\u540e\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5982\u4e0b\uff1a (?&amp;lt;!\\d)(\\d{3})(?!\\d) (?&lt;!d)\uff1a\u8d1f\u5411\u524d\u77bb\u65ad\u8a00\uff0c\u786e\u4fdd\u5339\u914d\u7684\u6570\u5b57\u5e8f\u5217\u4e4b\u524d\u6ca1\u6709\u6570\u5b57\u5b57\u7b26\u3002 (d{3})\uff1a\u6355\u83b7\u7ec4\uff0c\u5339\u914d\u6070\u597d\u4e09\u4e2a\u8fde\u7eed\u6570\u5b57\u3002 (?!d)\uff1a\u8d1f\u5411\u540e\u77bb\u65ad\u8a00\uff0c\u786e\u4fdd\u5339\u914d\u7684\u6570\u5b57\u5e8f\u5217\u4e4b\u540e\u6ca1\u6709\u6570\u5b57\u5b57\u7b26\u3002 python \u793a\u4f8b import re data = [ &#8216;123&#8217;, &#8216;123u&#8217;, &#8216;u123&#8217;, &#8216;x123y&#8217;, &#8216;1234&#8217;, &#8216;x1234y&#8217;, &#8217;12&#8217;, &#8216;123y456&#8242;, ] for s in data: print(re.findall(r'(?&amp;lt;!\\d)(\\d{3})(?!\\d)&#8217;, s)) \u8f93\u51fa\uff1a [&#8216;123&#8217;] [&#8216;123&#8217;] [&#8216;123&#8217;] [&#8216;123&#8217;] [] [] [] [&#8216;123&#8217;, &#8216;456&#8217;] \u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49803","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49803"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49803\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}