{"id":397127,"date":"2021-03-18T13:29:21","date_gmt":"2021-03-18T05:29:21","guid":{"rendered":"http:\/\/4563.org\/?p=397127"},"modified":"2021-03-18T13:29:21","modified_gmt":"2021-03-18T05:29:21","slug":"%e6%9c%89%e6%b2%a1%e6%9c%89%e4%bb%80%e4%b9%88%e8%b7%a8%e8%af%ad%e8%a8%80%e7%9a%84%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8fregex%e5%ae%9e%e7%8e%b0%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=397127","title":{"rendered":"\u6709\u6ca1\u6709\u4ec0\u4e48\u201c\u8de8\u8bed\u8a00\u201d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f(RegEx)\u5b9e\u73b0\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6709\u6ca1\u6709\u4ec0\u4e48\u201c\u8de8\u8bed\u8a00\u201d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f(RegEx)\u5b9e\u73b0\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : AndyAO <\/span>  <span><i><\/i> 9<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6b63\u5219\u8868\u8fbe\u5f0f\u5728\u5404\u79cd\u8bed\u8a00\u4e0a\u7684\u5b9e\u73b0\u6709\u5f88\u591a\u7684\u533a\u522b\uff0c\u6240\u4ee5\u5728\u4f7f\u7528\u7684\u8fc7\u7a0b\u4e2d\u5e38\u5e38\u8981\u6ce8\u610f[1]\uff0c\u6709\u7684\u65f6\u5019\u9700\u8981\u82b1\u633a\u957f\u65f6\u95f4\u624d\u80fd\u591f\u79fb\u690d\u8fc7\u53bb\u3002<\/p>\n<p>\u6709\u6ca1\u6709\u4ec0\u4e48\uff0c\u6bd4\u8f83\u51fa\u540d\u7684\uff0c\u8de8\u8bed\u8a00\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5b9e\u73b0\uff1f<\/p>\n<p>\u6bd4\u8f83\uff0c\u51fa\u540d\u7684\u8bed\u8a00\u5e94\u8be5\u90fd\u652f\u6301\uff0c\u4f8b\u5982 Python\uff0cJava\uff0cC#\uff0cJavaScript\uff0cGo \u7b49<\/p>\n<p>\u5982\u679c\u6709\u7684\u8bdd\u5c31\u80fd\u591f\u5b9e\u73b0\u4e00\u5904\u7f16\u5199\u5904\u5904\u8fd0\u884c\u4e86\u3002<\/p>\n<p>\u80cc\u666f\uff1a \u5728\u5b66\u4e60\u7684\u65f6\u5019\uff0c\u521a\u5f00\u59cb\u7528\u7684\u662f PowerShell\uff0c\u53d1\u73b0\u6709\u5f88\u591a\u7684\u8868\u8fbe\u5f0f\u5728\u4e0a\u9762\u8fd0\u884c\u662f\u6709\u95ee\u9898\u7684\uff0c\u4e3a\u4e86\u4e0d\u5728\u8fd9\u4e0a\u9762\u6d6a\u8d39\u65f6\u95f4\uff0c\u6700\u540e\u8fd8\u662f\u9009\u4e86\u548c\u8fd9\u672c\u4e66\u76f8\u540c\u7684 Python\uff0c\u7a81\u7136\u89c9\u5f97\u4e5f\u8bb8\u4f1a\u6709\u6bd4\u8f83\u51fa\u540d\u7684\u8de8\u5e73\u53f0\u7684\u5b9e\u73b0\uff0c\u5982\u679c\u771f\u662f\u90a3\u6837\u7684\u8bdd\uff0c\u90a3\u4e48\u5c31\u597d\u591a\u4e86\uff0c\u4e4b\u540e\u7528\u7684\u65f6\u5019\u5c31\u53ef\u4ee5\u4ece\u81ea\u5df1\u5df2\u7ecf\u5199\u597d\u7684\u8868\u8fbe\u5f0f\u4e2d\u76f4\u63a5\u590d\u5236\u7c98\u8d34\uff0c\u800c\u4e0d\u7528\u63d0\u5fc3\u540a\u80c6\u3002\u53bb\u8c37\u6b4c\u4e0a\u641c\u7d22<code>Cross platform Cross language RegEx<\/code>\uff0c\u6ca1\u770b\u5230\u5565\u6709\u7528\u7684\u4fe1\u606f\uff0c\u6240\u4ee5\u51c6\u5907\u6765\u95ee\u95ee\uff0c\u4e5f\u8bb8\u5728 V2EX \u6709\u4eba\u77e5\u9053\u3002<\/p>\n<p>[1]\uff1a\u300a\u6b63\u5219\u6307\u5f15\u300b<\/p>\n<p>\u8981\u77e5\u9053\uff0c\u4e00\u79cd\u8bed\u8a00\u4e0b\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5f80\u5f80\u5e76\u4e0d\u80fd\u76f4\u63a5\u5957\u7528\u5230\u53e6\u4e00\u79cd\u8bed\u8a00\u4e2d<\/p>\n<p>&#8230;<\/p>\n<p>\u672c\u4e66\u8fd8\u6db5\u76d6\u4e86.NET \u3001Java \u3001JavaScript \u3001PHP \u3001Python \u3001Ruby \u3001Objective-C \u3001Golang \u7b49\u5e38\u7528\u8bed\u8a00\uff0c\u4e3a\u6bcf\u79cd\u8bed\u8a00\u4e13\u95e8\u64b0\u5199\u76f8\u5173\u5185\u5bb9\uff0c\u4e0d\u4f46\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u8bed\u8a00\u4e2d\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u7528\u6cd5\uff0c\u66f4\u8fa8\u6790\u4e86\u7248\u672c\u4e4b\u95f4\u7684\u7ec6\u5fae\u5dee\u5f02\uff0c\u65e2\u53ef\u4ee5\u4f5c\u4e3a\u4e13\u95e8\u5b66\u4e60\u7684\u6559\u6750\uff0c\u4e5f\u53ef\u4ee5\u6210\u4e3a\u6709\u7528\u7684\u53c2\u8003\u624b\u518c\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>15<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5501204\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : acmore <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             ANTLR \u53ef\u4ee5\u6ee1\u8db3\uff0c\u4f46\u6709\u4e9b\u5927\u6750\u5c0f\u7528\uff0c\u5199\u914d\u7f6e\u4e5f\u6709\u4e9b\u7e41\u590d\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501205\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : agagega <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f88\u591a\u8bed\u8a00\u7684\u6b63\u5219\u90fd\u662f pcre \u517c\u5bb9\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501206\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : guyeu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u5217\u7684\u8fd9\u4e9b\u8bed\u8a00\u652f\u6301\u7684\u90fd\u662f PCRE \u6807\u51c6\u7684\u6b63\u5219\u5427\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501207\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hxndg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5e94\u8be5\u4e0d\u80fd\u628a\uff0c\u53cd\u6b63\u6211\u8bb0\u5f97\u662f\u5404\u79cd\u6d41\u6d3e\u90fd\u6709\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501208\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : missdeer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             PCRE \u5427\uff0c\u5f88\u591a\u8bed\u8a00\u6709\u517c\u5bb9\u6216\u7ed1\u5b9a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501209\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AndyAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b83\u4eec\u5e76\u4e0d\u662f\u517c\u5bb9\u7684\uff0c\u8fd9\u4e2a\u9700\u8981\u7279\u522b\u5f3a\u8c03\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501210\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mcfog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/github.com\/google\/re2<\/p>\n<p>RE2&#8217;s native language is C++.<\/p>\n<p>The Python wrapper is at https:\/\/github.com\/google\/re2\/tree\/abseil\/python<br \/>and on PyPI ( https:\/\/pypi.org\/project\/google-re2\/).<\/p>\n<p>A C wrapper is at https:\/\/github.com\/marcomaggi\/cre2\/.<br \/>An Erlang wrapper is at https:\/\/github.com\/dukesoferl\/re2\/ and on Hex (hex.pm).<br \/>An Inferno wrapper is at https:\/\/github.com\/powerman\/inferno-re2\/.<br \/>A Node.js wrapper is at https:\/\/github.com\/uhop\/node-re2\/ and on NPM (npmjs.com).<br \/>An OCaml wrapper is at https:\/\/github.com\/janestreet\/re2\/ and on OPAM (opam.ocaml.org).<br \/>A Perl wrapper is at https:\/\/github.com\/dgl\/re-engine-RE2\/ and on CPAN (cpan.org).<br \/>An R wrapper is at https:\/\/github.com\/qinwf\/re2r\/ and on CRAN (cran.r-project.org).<br \/>A Ruby wrapper is at https:\/\/github.com\/mudge\/re2\/ and on RubyGems (rubygems.org).<br \/>A WebAssembly wrapper is at https:\/\/github.com\/google\/re2-wasm\/ and on NPM (npmjs.com).<\/p>\n<p>\u53e6\u5916 Go \u6807\u51c6\u5e93\u7684\u6b63\u5219\u4e5f\u662f\u53c2\u7167 re2 \u7684                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501211\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jtsai <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u600e\u4e48\u611f\u89c9\u6b63\u5219\u5728\u6240\u6709\u8bed\u8a00\u91cc\u90fd\u5dee\u4e0d\u591a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501212\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AndyAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u521a\u521a\u770b\u4e86\u4e0a\u9762\u51e0\u4f4d\u8bf4\u90fd\u662f\u8fd9\u4e9b\u8bed\u8a00\u5185\u7f6e\u7684 RegEx \u662f\u517c\u5bb9\u7684\uff0c\u800c\u8fd9\u663e\u7136\u4e0d\u53ef\u80fd\uff0c\u5982\u679c\u662f\u8fd9\u6837\u7684\u8bdd\uff0c\u90a3\u4e48\u4e66\u5c31\u4e0d\u4f1a\u82b1\u8fd9\u4e48\u591a\u65f6\u95f4\u6765\u7279\u522b\u7684\u8bf4\u660e\uff0cRegexBuddy4 \u8fd9\u79cd\u4e13\u95e8\u7684\u5de5\u5177\u4e5f\u4e0d\u4f1a\u6709\u5404\u79cd\u8bed\u8a00\u7684\u9009\u9879\u8bbe\u7f6e\u3002<\/p>\n<p>\u4f46`PCRE`\u8fd9\u4e2a\u4fe1\u606f\u633a\u597d\uff0c\u5728\u67e5\u8be2\u76f8\u5173\u7684\u4fe1\u606f\uff0c\u4e5f\u8bb8\u8fd9\u4e2a\u5173\u952e\u8bcd\u53ef\u4ee5\u641c\u51fa\u5f88\u591a\u80fd\u5b8c\u5168\u517c\u5bb9\u7684\u7c7b\u5e93\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501213\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AndyAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u5dee\u4e0d\u591a\u662f\u5f88\u6b63\u5e38\u7684\uff0c\u56e0\u4e3a\u300c\u591a\u300d\u548c\u300c\u5c11\u300d\u8fd9\u4e9b\u8bcd\u90fd\u5f88\u6a21\u7cca\uff0c\u8fd9\u4e2a\u5e16\u5b50\u8ba8\u8bba\u7684\u5c31\u662f\u533a\u522b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501214\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AndyAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u641c\u7d22 Python PCRE \u80fd\u627e\u5230\u5ba3\u79f0\u66f4\u597d\u517c\u5bb9\u7684\u5e93\uff0c\u4f46\u662f\u4e0b\u8f7d\u91cf\u5c11\u7684\u53ef\u601c<\/p>\n<p>python-pcre \u00b7 PyPI<\/p>\n<p>https:\/\/pypi.org\/project\/python-pcre                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501215\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AndyAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ece\u8fd9\u91cc\u6765\u770b Python \u4e2d\u6709\u4e2a\u6a21\u5757\u5c31\u53eb RegEx \u63d0\u4f9b\u4e86\u5f88\u591a\u5b98\u65b9 re \u4e2d\u6ca1\u6709\u7684\u529f\u80fd\u3002<br \/>\u672c\u6765\u4ee5\u4e3a\u4f1a\u6709\u4eba\u7edf\u4e00\u7684\u53bb\u505a\u8fd9\u6837\u7684\u6a21\u5757\uff0c\u73b0\u5728\u770b\u6765\u4e5f\u8bb8\u5e76\u4e0d\u662f\u8fd9\u6837\u7684\uff0c\u8fd8\u662f\u6709\u7684\uff0c\u53ea\u662f\u540d\u5b57\u548c\u7ef4\u62a4\u8005\u4e0d\u76f8\u540c\u3002<\/p>\n<p>How can I use PCRE regexes from a python script?<br \/>https:\/\/stackoverflow.com\/a\/23212557                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501216\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AndyAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             mcfog \u63d0\u4f9b\u4e86\u5f88\u597d\u7684\u4fe1\u606f\uff0c\u539f\u6765 Python \u7684 re \u662f\u6765\u81ea C++ \u7684 re2\uff0c\u800c\u4e14\u6709\u5927\u91cf\u7684\u8bed\u8a00\u4e5f\u7528\u4e86\u8fd9\u4e2a\u5b9e\u73b0\uff0c\u770b\u6765 re2 \u5c31\u662f\u6211\u60f3\u627e\u7684\u4e1c\u897f\u4e4b\u4e00\uff0c\u5728 .NET \u4e0a\u4e5f\u53ef\u4ee5\u7528\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501217\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : AndyAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u554a\uff0c\u611f\u89c9\u597d\u50cf\u7406\u89e3\u9519\u4e86 Python \u7684 Re2 \u662f\u5728\u8fd9\u91cc \uff0cREADME \u4e0a\u6ca1\u8bf4\u5185\u7f6e\u7684\u662f\u2193<\/p>\n<p>[google-re2 \u00b7 PyPI]( https:\/\/pypi.org\/project\/google-re2\/)                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5501218\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : newmlp <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u641e\u4e2a CC++\u8bed\u8a00\u7684\u5e93\u5c31\u884c\u4e86\uff0c\u5e94\u8be5\u6ca1\u6709\u8bed\u8a00\u4e0d\u652f\u6301 CC++\u5e93\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u6ca1\u6709\u4ec0\u4e48\u201c\u8de8\u8bed\u8a00\u201d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f(&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/397127"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=397127"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/397127\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=397127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=397127"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=397127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}