{"id":157540,"date":"2020-09-07T07:05:40","date_gmt":"2020-09-06T23:05:40","guid":{"rendered":"http:\/\/4563.org\/?p=157540"},"modified":"2020-09-07T07:05:40","modified_gmt":"2020-09-06T23:05:40","slug":"%e8%af%b7%e6%95%99%e4%b8%80%e4%b8%aa%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%ef%bc%8c%e5%9c%a8%e5%8c%b9%e9%85%8d-pattern1-%e7%9a%84%e6%9d%a1%e4%bb%b6%e4%b8%8b%ef%bc%8c%e8%bf%94%e5%9b%9e%e6%89%80","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=157540","title":{"rendered":"\u8bf7\u6559\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u5728\u5339\u914d pattern1 \u7684\u6761\u4ef6\u4e0b\uff0c\u8fd4\u56de\u6240\u6709 pattern2 \u7684\u5b57\u7b26\u4e32"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u5728\u5339\u914d pattern1 \u7684\u6761\u4ef6\u4e0b\uff0c\u8fd4\u56de\u6240\u6709 pattern2 \u7684\u5b57\u7b26\u4e32               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : billgreen1 <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>text1=\"worda wordb aaaa wordc wordd worde 10, 20 and 35.\" text2=\"wordf bbbbb wordg wordh 11, 20 and 35.\" text3=\"wordi 11, 33, 44.\" <\/code><\/pre>\n<p>\u8981\u6c42\u662f:\u5f53\u4e14\u4ec5\u5f53\u884c\u4e2d\u51fa\u73b0\u4e86 aaaa \u8fd9\u4e2a\u5b57\u7b26\u4e32, \u8fd4\u56de\u6240\u6709\u6570\u5b57.<\/p>\n<p>\u6211\u5c1d\u8bd5\u4e86\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<pre><code>import re  re.findall(r'(?:aaaa).*(d+)', text1) # ['5'] re.findall(r'(?:aaaa).*?(d+)', text1) # ['10'] # \u671f\u5f85\u7ed3\u679c\u662f[\"10\", \"20\", \"35\"]  # \u867d\u7136\u53ef\u4ee5\u8fd9\u6837\uff0c\u4f46\u662f\u6211\u5e0c\u671b\u80fd\u6709\u4e2a\u4e00\u884c\u7684\u6b63\u5219\uff0c\u800c\u4e0d\u662f\u5339\u914d 2 \u6b21 if re.findall(\"aaaa\", text1):     numbers = re.findall(\"(d+)\", text1) <\/code><\/pre>\n<p>\u5148\u884c\u8c22\u8fc7\u5566~<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3349813\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Herobs <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5173\u952e\u8bcd\uff1a\u65ad\u8a00                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3349814\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : calmzhu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ea\u60f3\u5230\u4e2a\u53ef\u4ee5\u505a\u5230\u4e00\u6b21\u5339\u914d\u63d0\u53d6\uff0c\u4f46\u9700\u8981\u81ea\u5df1\u5904\u7406\u8fc7\u6ee4\u7684\u3002<br \/>c = re.findall(r'(aaaa|d+)&#8217;,&#8217;worda wordb aaaa wordc wordd worde 10, 20 and 35.&#8217;)<br \/>&#8216;aaaa&#8217; in c and c.remove(&#8216;aaaa&#8217;)<\/p>\n<p>\u4e3b\u8bf4\u7684\u627e\u4e0d\u5230\uff0c\u611f\u89c9\u6709\u51b2\u7a81\u3002\u5c31\u50cf\u6807\u9898\u6240\u8a00\uff0c<\/p>\n<p>\u5fc5\u7136\u5b58\u5728 \u4e24\u6b65\u903b\u8f91<br \/>\u4e00\u4e2a\u662f\u8ddf\u636e pattern1 \uff08 p1) \u8fc7\u6ee4<br \/>\u4e00\u4e2a\u662f\u8ddf\u636e pattern2 \uff08 p2)\u63d0\u53d6<br \/>\u5e76\u4e14 p1 p2 \u662f\u4e00\u5bf9\u591a\uff0c\u5047\u8bbe\u5b58\u5728 pTrue \u53ef\u4ee5\u6ee1\u8db3 re.findall(pTrue,text1)\u53ef\u4ee5\u8fd4\u56de\u6240\u6709\u4e3b\u6240\u9700\u5b57\u7b26\u4e32<\/p>\n<p>\u6b63\u5219\u6a21\u5f0f\u662f\u8fde\u7eed\u53ef\u53d8\u6ed1\u52a8\u7a97\u53e3\u6216\u8005\u7a97\u53e3\u7ec4<\/p>\n<p>\u8981\u4e48\u7528\u4e00\u4e2a\u5927\u6ed1\u52a8\u7a97\u53e3 \u628a\u6240\u6709 p1 + p2 \u5168\u90e8\u8986\u76d6<\/p>\n<p>\u8981\u4e48\u4e00\u7ec4\u7a97\u53e3\u5206\u522b\u8986\u76d6 p2 \u628a p1 \u62c6\u5165\u6bcf\u4e2a p2<\/p>\n<p>\u4e0d\u7ba1\u54ea\u79cd\uff0c\u5373\u4f7f\u4f7f\u7528\u96f6\u6b3e\u65ad\u8a00\u7684\u60c5\u51b5\u4e0b, \u7a97\u53e3\u4e2d\u90fd\u4e00\u5b9a\u4f1a\u6709\u6709d+\u4e4b\u5916\u7684\u5176\u4ed6\u4fe1\u606f\u3002\u6bd4\u5982\u6211\u4e0a\u9762\u7684\u4f8b\u5b50\uff0c\u5c31\u5305\u542b\u4e86\u8fc7\u6ee4\u4fe1\u606f<\/p>\n<p>\u6216\u8005\u8bf4\u8fc7\u6ee4+\u63d0\u53d6\u4e24\u6b65\u903b\u8f91\u662f\u5fc5\u7136\u6709\u4e2d\u95f4\u7ed3\u679c\u7684\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u5728\u5339\u914d pat&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\/157540"}],"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=157540"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/157540\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157540"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}