{"id":214,"date":"2021-12-15T09:34:28","date_gmt":"2021-12-15T01:34:28","guid":{"rendered":"http:\/\/139.9.1.231\/?p=214"},"modified":"2021-12-15T09:40:45","modified_gmt":"2021-12-15T01:40:45","slug":"python-2","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2021\/12\/15\/python-2\/","title":{"rendered":"python \u6b63\u5219\u8868\u8fbe\u5f0f\u548cre\u6a21\u5757"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"214\" class=\"elementor elementor-214\" data-elementor-settings=\"[]\">\n\t\t\t\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-41144e4f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"41144e4f\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3d8f9eb9\" data-id=\"3d8f9eb9\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5d0a601b elementor-widget elementor-widget-text-editor\" data-id=\"5d0a601b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<!-- wp:heading -->\n<h2>\u6b63\u5219\u8868\u8fbe\u5f0f<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p><\/p>\n<!-- \/wp:paragraph -->\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-cf293ee elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"cf293ee\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9787b10\" data-id=\"9787b10\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b2a483d elementor-widget-divider--view-line elementor-widget elementor-widget-divider\" data-id=\"b2a483d\" data-element_type=\"widget\" data-widget_type=\"divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-divider\">\n\t\t\t<span class=\"elementor-divider-separator\">\n\t\t\t\t\t\t<\/span>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7465db9 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7465db9\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-47dee00\" data-id=\"47dee00\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e5076fa elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e5076fa\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b5304e2\" data-id=\"b5304e2\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-7619b04 elementor-widget elementor-widget-text-editor\" data-id=\"7619b04\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><span style=\"color: #404040; font-family: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', Courier, monospace; font-size: 12px; white-space: pre; font-weight: var( --e-global-typography-text-font-weight );\">. \u70b9\u53f7\uff0c\u5728\u9ed8\u8ba4\u6a21\u5f0f\u4e0b\uff0c\u5339\u914d\u9664\u6362\u884c\u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26\u3002\u5982\u679c DOTALL \u6807\u5fd7\u88ab\u6307\u5b9a, \u5219\u5339\u914d\u5305\u62ec\u6362\u884c\u7b26\u5728\u5185\u7684\u6240\u6709\u5b57\u7b26\u3002<\/span><\/p>\n<pre style=\"font-family: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', Courier, monospace; font-size: 12px; white-space: pre; margin-bottom: 0px; padding: 12px; line-height: 1.4; color: #404040;\">^    \u4e58\u65b9\u8fd0\u7b97\u7b26\u6216\u8131\u5b57\u8282\u7b26\uff0c\u5728\u9ed8\u8ba4\u6a21\u5f0f\u4e0b\u5339\u914d\u5b57\u7b26\u4e32\u7684\u8d77\u59cb\u4f4d\u7f6e\uff0c\u5728MULTILINE\u6a21\u5f0f\u4e0b\u4e5f\u5339\u914d\u6362\u884c\u7b26\u4e4b\u540e\u7684\u4f4d\u7f6e\u3002\n$    \u5339\u914d\u5b57\u7b26\u4e32\u7684\u672b\u5c3e\u6216\u8005\u5b57\u7b26\u4e32\u672b\u5c3e\u6362\u884c\u7b26\u4e4b\u524d\u7684\u4f4d\u7f6e\uff0c\u5728MULTILINE\u6a21\u5f0f\u4e0b\u8fd8\u5339\u914d\u6362\u884c\u7b26\u4e4b\u524d\u7684\u4f4d\u7f6e\u3002\n*    \u5339\u914d\u524d\u9762\u91cd\u590d\u51fa\u73b0\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u96f6\u6b21\u6216\u591a\u6b21\uff0c\u5c3d\u53ef\u80fd\u591a\u7684\u5339\u914d(greedy \u8d2a\u5a6a\u578b)\u3002\n+    \u5339\u914d\u524d\u9762RE 1\u6b21\u6216\u591a\u6b21(\u8d2a\u5a6a\u578b\uff0c\u5c3d\u53ef\u80fd\u591a\u7684\u5339\u914d)\u3002\n?    \u5339\u914d\u524d\u9762\u7684RE 0\u6b21\u62161\u6b21\u3002\n*?,+?,??    '*'\u3001'+'\u548c'?'\u9650\u5b9a\u7b26\u662f\u8d2a\u5a6a\u7684\uff1b\u5b83\u4eec\u5339\u914d\u5c3d\u53ef\u80fd\u591a\u7684\u6587\u672c\u3002\u5728\u9650\u5b9a\u7b26\u4e4b\u540e\u52a0\u4e0a'?'\u5c06\u4f7f\u5f97\u5339\u914d\u4ee5\u975e\u8d2a\u5a6a\u7684\u6216\u6700\u5c0f\u7684\u65b9\u5f0f\u8fdb\u884c\u3002\n{m}        \u8868\u793a\u7cbe\u786e\u5339\u914d\u524d\u9762\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u7684m\u4e2a\u62f7\u8d1d\uff0c\u8f83\u5c11\u7684\u5339\u914d\u5c06\u5bfc\u81f4\u6574\u4e2a\u8868\u8fbe\u5f0f\u4e0d\u80fd\u5339\u914d\u3002\n{m,n}    \u5339\u914d\u524d\u5bfc\u6b63\u5219\u8868\u8fbe\u5f0f\u7684m\u5230n\u4e2a\u91cd\u590d\uff0c\u5c1d\u8bd5\u5339\u914d\u5c3d\u53ef\u80fd\u591a\u7684\u91cd\u590d(greedy \u8d2a\u5a6a\u578b)\u3002\n{m,}    \u5339\u914d\u524d\u5bfc\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u81f3\u5c11m\u6b21\uff0c\u5c1d\u8bd5\u5339\u914d\u5c3d\u53ef\u80fd\u591a\u7684\u91cd\u590d(greedy \u8d2a\u5a6a\u578b)\u3002\n{,n}    \u5339\u914d\u524d\u5bfc\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u81f3\u591an\u6b21\uff0c\u5c1d\u8bd5\u5339\u914d\u5c3d\u53ef\u80fd\u591a\u7684\u91cd\u590d(greedy \u8d2a\u5a6a\u578b)\u3002\n{m,n}?    \u5339\u914d\u524d\u5bfc\u6b63\u5219\u8868\u8fbe\u5f0f\u7684m\u5230n\u4e2a\u91cd\u590d\uff0c\u5c1d\u8bd5\u5339\u914d\u5c3d\u53ef\u80fd\u5c11\u7684\u91cd\u590d(Non-greedy \u975e\u8d2a\u5a6a\u578b)\u3002\n\\        \u5bf9\u7279\u6b8a\u7b26\u53f7\u8fdb\u884c\u8f6c\u4e49\n[]        \u7528\u6765\u8868\u793a\u4e00\u4e2a\u5b57\u7b26\u96c6\u5408\u3002\n        \u5b57\u7b26\u53ef\u4ee5\u4e00\u4e2a\u4e00\u4e2a\u7684\u5217\u51fa\u6765\uff0c\u5982[abcd]\uff0c\u5219\u53ef\u4ee5\u5339\u914d'a','b','c','d'\u3002\n        \u901a\u8fc7\u7ed9\u51fa\u4e24\u4e2a\u5b57\u7b26\u5e76\u7528'-'\u5206\u9694\uff0c\u53ef\u4ee5\u7ed9\u51fa\u4e00\u6bb5\u8303\u56f4\u7684\u5b57\u7b26\uff0c\u5982[a-z]\u5339\u914d\u5c0f\u5199\u5b57\u6bcd\uff0c[A-Z]\u5339\u914d\u5927\u5199\u5b57\u6bcd\uff0c[0-9]\u5339\u914d0-9\u7684\u6570\u5b57\u3002\n        \u5728\u96c6\u5408\u5185\u90e8\uff0c\u7279\u6b8a\u5b57\u7b26\u5c06\u5931\u53bb\u5b83\u4eec\u7279\u6b8a\u7684\u542b\u4e49\uff0c\u5982[(+*)]\u5c06\u5339\u914d'(','+','*',')'\u3002\n        \u5728\u96c6\u5408\u4e2d\u63a5\u53d7\u5b57\u7b26\u7c7b\u522b\\s,\\S,\\w\u7b49\u3002\n        \u53ef\u4ee5\u4f7f\u7528[^RE]\u4f5c\u4e3a\u5b57\u7b26\u96c6\u7684\u8865\u96c6\uff0c^\u5fc5\u987b\u4e3a\u96c6\u5408\u7b2c\u4e00\u4e2a\u5b57\u7b26\uff0c\u5982[^a-z]\u53ef\u4ee5\u5339\u914d\u9664\u5c0f\u5199\u5b57\u6bcd\u5916\u6240\u6709\u7684\u5b57\u7b26\u3002\n|        a|b \u5339\u914da\u6216b\uff0c(Non-greedy \u975e\u8d2a\u5a6a\u578b)\uff0c\u5339\u914d\u4e0a\u6b63\u5219a\u540e\uff0c\u5c31\u4e0d\u4f1a\u518d\u53bb\u5c1d\u8bd5\u5339\u914d\u6b63\u5219b\u3002\n(...)    \u88ab\u5706\u62ec\u53f7\u62ec\u8d77\u6765\u7684\u8868\u8fbe\u5f0f\u5c06\u4f5c\u4e3a\u5206\u7ec4\uff0c\u5206\u7ec4\u8868\u8fbe\u5f0f\u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\uff0c\u540e\u9762\u53ef\u4ee5\u63a5\u6570\u91cf\u8bcd\uff0c\u8868\u8fbe\u5f0f\u4e2d|\u4ec5\u5728\u8be5\u7ec4\u4e2d\u6709\u6548\u3002\n        \u5982(a-z|A-Z){2,3}\u8868\u793a\u5339\u914d\u5b57\u6bcd2\u81f33\u6b21\u3002\n(?aiLmsux)    \u7ed9\u6574\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u8bbe\u7f6e\u76f8\u5e94\u7684\u6807\u8bb0\uff1are.A\uff08ASCII\u7801\u6a21\u5f0f\uff09\uff0cre.I\uff08\u5ffd\u7565\u5927\u5c0f\u5199\uff09\uff0cre.L\uff08\u4f9d\u8d56\u533a\u57df\u8bbe\u7f6e\uff09;\n            re.M\uff08\u591a\u884c\u6a21\u5f0f\uff09\uff0cre.S\uff08\u70b9\u53f7\u5339\u914d\u6240\u6709\u5b57\u7b26\uff09\uff0cre.U\uff08\u4f9d\u8d56Unicode\uff09\uff0cre.X\uff08\u8be6\u7ec6\u6a21\u5f0f\uff09\n(?:...)    # \u5f53\u4f60\u8981\u5c06\u4e00\u90e8\u5206\u89c4\u5219\u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\u5bf9\u5b83\u8fdb\u884c\u67d0\u4e9b\u64cd\u4f5c\uff0c\u53ef\u4ee5\u4f7f\u7528(?:RE)\u5c06\u6b63\u5219\u8868\u8fbe\u5f0fRE\u5305\u88f9\u8d77\u6765\u3002\n(?P&lt;name&gt;...)    # \u5c06RE\u5b57\u7b26\u4e32\u5305\u88f9\u8fdb\u6765\u4f5c\u4e3a\u4e00\u4e2a\u547d\u540d\u7ec4\u3002\n(?P=name)        # \u4f7f\u7528\u547d\u540d\u7ec4\u8fdb\u884c\u5339\u914d\u3002\u5339\u914d\u524d\u9762\u5b9a\u4e49\u7684\u547d\u540d\u7ec4\u5339\u914d\u5230\u7684\u5b57\u7b26\u4e32\u3002\n(?#...)            # \u6dfb\u52a0\u5907\u6ce8\uff0c\u5ffd\u7565\u6307\u5b9a\u7684\u5b57\u7b26\u3002\n(?='...')        # \u5982\u679c\u6307\u5b9a\u7684\u5b57\u7b26\u5728\u5339\u914d\u5230\u7684\u5b57\u7b26\u540e\u9762\uff0c\u624d\u7b97\u5339\u914d\u6210\u529f\u3002s='Isaac Asimov'   m=re.findall(\"Isaac (?=Asimov)\",s)\n(?!...)            # \u5982\u679c\u6307\u5b9a\u7684\u5b57\u7b26\u4e0d\u5728\u5339\u914d\u5230\u7684\u5b57\u7b26\u540e\u9762\uff0c\u624d\u7b97\u5339\u914d\u6210\u529f\u3002s='Isaac Asimov'   m=re.findall(\"Isaac (?!Asimov)\",s)\n(?&lt;=...)         # \u5982\u679c\u6307\u5b9a\u7684\u5b57\u7b26\u5728\u5339\u914d\u5230\u7684\u5b57\u7b26\u524d\u9762\uff0c\u624d\u7b97\u5339\u914d\u6210\u529f\u3002s='Isaac Asimov'   m=re.findall(\"(?&lt;=Isaac )Asimov\",s)\n(?&lt;!...)        # \u5982\u679c\u6307\u5b9a\u7684\u5b57\u7b26\u4e0d\u5728\u5339\u914d\u5230\u7684\u5b57\u7b26\u524d\u9762\uff0c\u624d\u7b97\u5339\u914d\u6210\u529f\u3002s='Isaac Asimov'   m=re.findall(\"(?&lt;!Isaac )Asimov\",s)\n(?(id\/name)yes|no)        #\u9009\u62e9\u6027\u5339\u914d (?(id\/name)yes-pattern|no-pattern) \u7684\u4f5c\u7528\u662f\uff1a\n                            \u5bf9\u4e8e\u7ed9\u51fa\u7684id\u6216\u8005name\uff0c\u5148\u5c1d\u8bd5\u53bb\u5339\u914d yes-pattern\u90e8\u5206\u7684\u5185\u5bb9\uff1b\n                            \u5982\u679cid\u6216name\u6761\u4ef6\u4e0d\u6ee1\u8db3\uff0c\u5219\u53bb\u5339\u914dno-pattern\u90e8\u5206\u7684\u5185\u5bb9\uff1bno-pattern\u90e8\u5206\u53ef\u4ee5\u7701\u7565\uff1b\n                            \u6b64\u5904\u7684name\u6216id\uff0c\u662f\u9488\u5bf9\uff08\u5f53\u524d\u4f4d\u7f6e\u7684\uff09\u6761\u4ef6\u6027\u5339\u914d\u4e4b\u524d\u7684\uff0c\u67d0\u4e2a\u5df2\u7ecf\u901a\u8fc7group\u53bb\u5206\u7ec4\u7684\u5185\u5bb9\n                            \u5982\u679c\u662f\u6709\u547d\u540d\u7684\u5206\u7ec4\uff0c\u5373named group\uff0c\u5219\u5bf9\u5e94\u7684\u8be5\u5206\u7ec4\u5c31\u6709\u5bf9\u5e94\u7684name\uff0c\u5373\u6b64\u5904\u6240\u6307\u7684\u5c31\u662f\u5bf9\u5e94\u7684name\uff1b\n                            \u5982\u679c\u662f\u65e0\u547d\u540d\u7684\u5206\u7ec4\uff0c\u5373unnamed group\uff0c\u5219\u5bf9\u5e94\u7684\u8be5\u5206\u7ec4\u4e5f\u6709\u5bf9\u5e94\u7684\u5206\u7ec4\u7684\u7f16\u53f7\uff0c\u79f0\u4e3agroup\u7684number\uff0c\n                            \u4e5f\u53eb\u505aid\uff0c\u5bf9\u5e94\u7684\u5c31\u662f\u8fd9\u91cc\u7684id\u3002\n    *** \u9884\u5b9a\u4e49\u5b57\u7b26\u96c6\n\\\\        \u5339\u914d\u53cd\u659c\u6760\n\\A        \u5339\u914d\u5b57\u7b26\u4e32\u5f00\u5934\uff0c\u540c^\n\\Z        \u5339\u914d\u5b57\u7b26\u4e32\u7ed3\u5c3e\uff0c\u540c$\n\\number    \u5339\u914d\u76f8\u540c\u7f16\u53f7\u7684\u7ec4\u7684\u5185\u5bb9\n\\b        \u5339\u914d\u7a7a\u5b57\u7b26\u4e32\uff0c\u4ec5\u5728\u8bcd\u7684\u5f00\u5934\u548c\u7ed3\u5c3e\n\\B        \u5339\u914d\u7a7a\u5b57\u7b26\u4e32\uff0c\u4e0d\u5728\u8bcd\u7684\u5f00\u5934\u548c\u7ed3\u5c3e\uff0c\u4e0e\\b\u76f8\u53cd\n\\d        \u5339\u914d\u6570\u5b57,\u7b49\u540c\u4e8e[0-9]\n\\D        \u5339\u914d\u975e\u6570\u5b57\uff0c\u7b49\u540c\u4e8e\\d\u7684\u8865\u96c6\uff0c\u5373[^\\d]\n\\s        \u5339\u914dwhitespace\u5b57\u7b26\u4e32\uff0c\u540c\u7b49\u4e8e[ \\t\\n\\r\\f\\v]\n\\S        \u5339\u914d\u975ewhitespace\u5b57\u7b26\u4e32\uff0c\\s\u7684\u8865\u96c6\uff0c[^\\s]\n\\w        \u5339\u914d\u5b57\u6bcd\uff0c\u6570\u5b57\uff0c\u4e0b\u5212\u7ebf\uff0c\u7b49\u540c\u4e8e[a-zA-Z0-9_]\n\\W        \\w\u7684\u8865\u96c6<\/pre>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a8f790d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"a8f790d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-44df4da\" data-id=\"44df4da\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d141827 elementor-widget elementor-widget-text-editor\" data-id=\"d141827\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<h2 style=\"font-family: 'Roboto Slab', ff-tisa-web-pro, Georgia, Arial, sans-serif; font-size: 24px; color: #404040; background-color: #fcfcfc;\"><a class=\"toc-backref\" style=\"color: #404040; cursor: pointer;\" href=\"https:\/\/hellopython.readthedocs.io\/zh_CN\/latest\/re_module.html#id19\">\u4f7f\u7528re\u6a21\u5757\u7684\u6b65\u9aa4<\/a><\/h2>\n<p style=\"line-height: 24px; margin-bottom: 24px; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; background-color: #fcfcfc;\">\u6211\u4eec\u6709\u5fc5\u8981\u5bf9re\u6a21\u5757\u4e2d\u6240\u5305\u542b\u7684\u7c7b\u53ca\u5176\u5de5\u4f5c\u6d41\u7a0b\u8fdb\u884c\u4e00\u4e0b\u7b80\u5355\u7684\u3001\u6574\u4f53\u6027\u7684\u8bf4\u660e\uff0c\u8fd9\u8bb2\u6709\u5229\u4e8e\u6211\u4eec\u5bf9\u4e0b\u9762\u5185\u5bb9\u7684\u7406\u89e3\u3002<\/p>\n<p style=\"line-height: 24px; margin-bottom: 24px; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; background-color: #fcfcfc;\">\u4f7f\u7528re\u6a21\u5757\u8fdb\u884c\u6b63\u5219\u5339\u914d\u64cd\u4f5c\u7684\u6b65\u9aa4:<\/p>\n<ul class=\"simple\" style=\"margin-bottom: 24px; line-height: 24px; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; background-color: #fcfcfc;\">\n<li style=\"list-style: disc; margin-left: 24px;\">\u7f16\u5199\u8868\u793a\u6b63\u5219\u8868\u8fbe\u5f0f\u89c4\u5219\u7684Python\u5b57\u7b26\u4e32str\uff1b<\/li>\n<li style=\"list-style: disc; margin-left: 24px;\">\u901a\u8fc7re.compile()\u51fd\u6570\u7f16\u8bd1\u8be5Python\u5b57\u7b26\u4e32\u83b7\u5f97\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u8c61\uff08Pattern Object\uff09p\uff1b<\/li>\n<li style=\"list-style: disc; margin-left: 24px;\">\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u8c61\u7684p.match()\u6216p.fullmatch()\u51fd\u6570\u83b7\u53d6\u5339\u914d\u7ed3\u679c\u2013\u5339\u914d\u5bf9\u8c61\uff08Match Object\uff09m;<\/li>\n<li style=\"list-style: disc; margin-left: 24px;\">\u901a\u8fc7\u5224\u65ad\u5339\u914d\u5bf9\u8c61m\u662f\u5426\u4e3a\u7a7a\u53ef\u77e5\u662f\u5426\u5339\u914d\u6210\u529f\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5339\u914d\u5bf9\u8c61m\u63d0\u4f9b\u7684\u65b9\u6cd5\u83b7\u53d6\u5339\u914d\u5185\u5bb9\u3002<\/li>\n<\/ul>\n<p style=\"line-height: 24px; margin-bottom: 24px; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; background-color: #fcfcfc;\">\u4f7f\u7528re\u6a21\u5757\u8fdb\u884c\u5185\u5bb9\u67e5\u627e\u3001\u66ff\u6362\u548c\u5b57\u7b26\u4e32\u5206\u9694\u64cd\u4f5c\u7684\u6b65\u9aa4:<\/p>\n<ul class=\"simple\" style=\"margin-bottom: 24px; line-height: 24px; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; background-color: #fcfcfc;\">\n<li style=\"list-style: disc; margin-left: 24px;\">\u7f16\u5199\u8868\u793a\u6b63\u5219\u8868\u8fbe\u5f0f\u89c4\u5219\u7684Python\u5b57\u7b26\u4e32str\uff1b<\/li>\n<li style=\"list-style: disc; margin-left: 24px;\">\u901a\u8fc7re.compile()\u51fd\u6570\u7f16\u8bd1\u8be5Python\u5b57\u7b26\u4e32\u83b7\u5f97\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u8c61\uff08Pattern Object\uff09p\uff1b<\/li>\n<li style=\"list-style: disc; margin-left: 24px;\">\u901a\u8fc7\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u8c61\u7684p.search()\u6216p.findall()\u6216p.finditer()\u6216p.sub()\u6216p.subn()\u6216p.split()\u51fd\u6570\u5b8c\u5185\u5bb9\u67e5\u627e\u3001\u66ff\u6362\u548c\u5b57\u7b26\u4e32\u5206\u9694\u64cd\u4f5c\u5e76\u83b7\u53d6\u76f8\u5e94\u7684\u64cd\u4f5c\u7ed3\u679c;<\/li>\n<\/ul>\n<p style=\"line-height: 24px; margin-bottom: 24px; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; background-color: #fcfcfc;\">\u603b\u7ed3\uff1a<\/p>\n<ul class=\"simple\" style=\"margin-bottom: 24px; line-height: 24px; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; background-color: #fcfcfc;\">\n<li style=\"list-style: disc; margin-left: 24px;\">\u6839\u636e\u4e0a\u9762\u7684\u63cf\u8ff0\u53ef\u77e5\uff0c\u5c06\u4e00\u4e2a\u8868\u793a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684Python\u5b57\u7b26\u4e32\u7f16\u8bd1\u6210\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u8c61\u662f\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5b8c\u6210\u76f8\u5e94\u529f\u80fd\u7684\u9996\u8981\u6b65\u9aa4.<\/li>\n<li style=\"list-style: disc; margin-left: 24px;\">re\u6a21\u5757\u4e2d\u7528\u4e8e\u5b8c\u6210\u6b63\u5219\u8868\u8fbe\u5f0f\u7f16\u8bd1\u529f\u80fd\u7684\u51fd\u6570\u4e3are.compile()\u3002<\/li>\n<\/ul>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-96b08e2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"96b08e2\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-bbd747b\" data-id=\"bbd747b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-05ccc85 elementor-widget elementor-widget-text-editor\" data-id=\"05ccc85\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><code class=\"sig-prename descclassname\">re.<\/code><code class=\"sig-name descname\">compile<\/code><span class=\"sig-paren\">(<\/span><em class=\"sig-param\"><span class=\"n\">pattern<\/span><\/em>,\u00a0<em class=\"sig-param\"><span class=\"n\">flags<\/span><span class=\"o\">=<\/span><span class=\"default_value\">0<\/span><\/em><span class=\"sig-paren\">)<\/span>\u5c06\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u6837\u5f0f\u7f16\u8bd1\u4e3a\u4e00\u4e2a\u00a0<a class=\"reference internal\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re-objects\"><span class=\"std std-ref\">\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u8c61<\/span><\/a>\u00a0\uff08\u6b63\u5219\u5bf9\u8c61\uff09\uff0c\u53ef\u4ee5\u7528\u4e8e\u5339\u914d\uff0c\u901a\u8fc7\u8fd9\u4e2a\u5bf9\u8c61\u7684\u65b9\u6cd5\u00a0<a class=\"reference internal\" title=\"re.Pattern.match\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.Pattern.match\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">match()<\/span><\/code><\/a>,\u00a0<a class=\"reference internal\" title=\"re.Pattern.search\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.Pattern.search\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">search()<\/span><\/code><\/a>\u00a0\u4ee5\u53ca\u5176\u4ed6\u5982\u4e0b\u63cf\u8ff0\u3002<\/p>\n<p>\u00a0<\/p>\n<div class=\"highlight-python3 notranslate\" style=\"clear: both; margin: 1em 0px; color: #222222; font-family: 'Lucida Grande', Arial, sans-serif; background-color: #ffffff; position: relative;\">\n<div class=\"highlight\" style=\"background: #f8f8f8;\">\n<pre style=\"overflow-y: hidden; clear: both; padding: 5px; background-color: #eeffcc; color: #333333; line-height: 19.3px; border-color: #aacc99; font-family: 'monospace', monospace; font-size: 15.44px; margin-bottom: 0px; border-radius: 3px;\"><span class=\"n\">prog<\/span> <span class=\"o\" style=\"color: #666666;\">=<\/span> <span class=\"n\">re<\/span><span class=\"o\" style=\"color: #666666;\">.<\/span><span class=\"n\">compile<\/span><span class=\"p\">(<\/span><span class=\"n\">pattern<\/span><span class=\"p\">)<\/span>\n<span class=\"n\">result<\/span> <span class=\"o\" style=\"color: #666666;\">=<\/span> <span class=\"n\">prog<\/span><span class=\"o\" style=\"color: #666666;\">.<\/span><span class=\"n\">match<\/span><span class=\"p\">(<\/span><span class=\"n\">string<\/span><span class=\"p\">)<\/span>\n<\/pre>\n<\/div>\n<\/div>\n<p style=\"hyphens: auto; line-height: 1.4; color: #222222; font-family: 'Lucida Grande', Arial, sans-serif; background-color: #ffffff;\">\u7b49\u4ef7\u4e8e<\/p>\n<div class=\"highlight-python3 notranslate\" style=\"clear: both; margin: 1em 0px; color: #222222; font-family: 'Lucida Grande', Arial, sans-serif; background-color: #ffffff; position: relative;\">\n<div class=\"highlight\" style=\"background: #f8f8f8;\">\n<pre style=\"overflow-y: hidden; clear: both; padding: 5px; background-color: #eeffcc; color: #333333; line-height: 19.3px; border-color: #aacc99; font-family: 'monospace', monospace; font-size: 15.44px; margin-bottom: 0px; border-radius: 3px;\"><span class=\"n\">result<\/span> <span class=\"o\" style=\"color: #666666;\">=<\/span> <span class=\"n\">re<\/span><span class=\"o\" style=\"color: #666666;\">.<\/span><span class=\"n\">match<\/span><span class=\"p\">(<\/span><span class=\"n\">pattern<\/span><span class=\"p\">,<\/span> <span class=\"n\">string<\/span><span class=\"p\">)<\/span><\/pre>\n<\/div>\n<\/div>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2f665c5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2f665c5\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-61fe1bb\" data-id=\"61fe1bb\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-60854c5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"60854c5\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a9e13f5\" data-id=\"a9e13f5\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-227451d elementor-widget elementor-widget-text-editor\" data-id=\"227451d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<dl class=\"py function\" style=\"margin-bottom: 15px; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\"><dt id=\"re.search\"><code class=\"sig-prename descclassname\" style=\"background-color: transparent; padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\">re.<\/code><code class=\"sig-name descname\" style=\"background-color: transparent; padding: 0px 1px; font-size: 19.2px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\">search<\/code><span class=\"sig-paren\" style=\"font-size: larger;\">(<\/span><em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\">pattern<\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\">string<\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\"><span class=\"n\">flags<\/span><span class=\"o\">=<\/span><span class=\"default_value\">0<\/span><\/em><span class=\"sig-paren\" style=\"font-size: larger;\">)<\/span><a class=\"headerlink\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.search\" title=\"\u6c38\u4e45\u94fe\u63a5\u81f3\u76ee\u6807\" style=\"color: rgb(0, 114, 170); visibility: hidden; font-size: 0.8em; padding: 0px 4px;\"><\/a><\/dt><dd style=\"margin-top: 3px; margin-bottom: 0px; margin-left: 30px; hyphens: auto; line-height: 1.4;\"><p style=\"hyphens: auto; line-height: 1.4; margin-bottom: 0px;\">\u626b\u63cf\u6574\u4e2a&nbsp;<em>\u5b57\u7b26\u4e32<\/em>&nbsp;\u627e\u5230\u5339\u914d\u6837\u5f0f\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u76f8\u5e94\u7684&nbsp;<a class=\"reference internal\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#match-objects\" style=\"color: rgb(0, 114, 170);\">\u5339\u914d\u5bf9\u8c61<\/a>\u3002\u5982\u679c\u6ca1\u6709\u5339\u914d\uff0c\u5c31\u8fd4\u56de\u4e00\u4e2a&nbsp;<code class=\"docutils literal notranslate\" style=\"background-color: rgb(236, 240, 243); padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\"><span class=\"pre\" style=\"hyphens: none;\">None<\/span><\/code>&nbsp;\uff1b \u6ce8\u610f\u8fd9\u548c\u627e\u5230\u4e00\u4e2a\u96f6\u957f\u5ea6\u5339\u914d\u662f\u4e0d\u540c\u7684\u3002<\/p><\/dd><\/dl><dl class=\"py function\" style=\"margin-bottom: 15px; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\"><dt id=\"re.match\"><code class=\"sig-prename descclassname\" style=\"background-color: transparent; padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\">re.<\/code><code class=\"sig-name descname\" style=\"background-color: transparent; padding: 0px 1px; font-size: 19.2px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\">match<\/code><span class=\"sig-paren\" style=\"font-size: larger;\">(<\/span><em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\">pattern<\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\">string<\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\"><span class=\"n\">flags<\/span><span class=\"o\">=<\/span><span class=\"default_value\">0<\/span><\/em><span class=\"sig-paren\" style=\"font-size: larger;\">)<\/span><a class=\"headerlink\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.match\" title=\"\u6c38\u4e45\u94fe\u63a5\u81f3\u76ee\u6807\" style=\"color: rgb(0, 114, 170); visibility: hidden; font-size: 0.8em; padding: 0px 4px;\"><\/a><\/dt><dd style=\"margin-top: 3px; margin-bottom: 0px; margin-left: 30px; hyphens: auto; line-height: 1.4;\"><p style=\"hyphens: auto; line-height: 1.4;\">\u5982\u679c&nbsp;<em>string<\/em>&nbsp;\u5f00\u59cb\u76840\u6216\u8005\u591a\u4e2a\u5b57\u7b26\u5339\u914d\u5230\u4e86\u6b63\u5219\u8868\u8fbe\u5f0f\u6837\u5f0f\uff0c\u5c31\u8fd4\u56de\u4e00\u4e2a\u76f8\u5e94\u7684&nbsp;<a class=\"reference internal\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#match-objects\" style=\"color: rgb(0, 114, 170);\">\u5339\u914d\u5bf9\u8c61<\/a>&nbsp;\u3002 \u5982\u679c\u6ca1\u6709\u5339\u914d\uff0c\u5c31\u8fd4\u56de&nbsp;<code class=\"docutils literal notranslate\" style=\"background-color: rgb(236, 240, 243); padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\"><span class=\"pre\" style=\"hyphens: none;\">None<\/span><\/code>&nbsp;\uff1b\u6ce8\u610f\u5b83\u8ddf\u96f6\u957f\u5ea6\u5339\u914d\u662f\u4e0d\u540c\u7684\u3002<\/p><p style=\"hyphens: auto; line-height: 1.4;\">\u6ce8\u610f\u5373\u4fbf\u662f&nbsp;<a class=\"reference internal\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.MULTILINE\" title=\"re.MULTILINE\" style=\"color: rgb(0, 114, 170);\"><code class=\"xref py py-const docutils literal notranslate\" style=\"background-color: transparent; padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\"><span class=\"pre\" style=\"hyphens: none;\">MULTILINE<\/span><\/code><\/a>&nbsp;\u591a\u884c\u6a21\u5f0f\uff0c&nbsp;<a class=\"reference internal\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.match\" title=\"re.match\" style=\"color: rgb(0, 114, 170);\"><code class=\"xref py py-func docutils literal notranslate\" style=\"background-color: transparent; padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\"><span class=\"pre\" style=\"hyphens: none;\">re.match()<\/span><\/code><\/a>&nbsp;\u4e5f\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\uff0c\u800c\u4e0d\u5339\u914d\u6bcf\u884c\u5f00\u59cb\u3002<\/p><p style=\"hyphens: auto; line-height: 1.4; margin-bottom: 0px;\">\u5982\u679c\u4f60\u60f3\u5b9a\u4f4d&nbsp;<em>string<\/em>&nbsp;\u7684\u4efb\u4f55\u4f4d\u7f6e\uff0c\u4f7f\u7528&nbsp;<a class=\"reference internal\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.search\" title=\"re.search\" style=\"color: rgb(0, 114, 170);\"><code class=\"xref py py-func docutils literal notranslate\" style=\"background-color: transparent; padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\"><span class=\"pre\" style=\"hyphens: none;\">search()<\/span><\/code><\/a>&nbsp;\u6765\u66ff\u4ee3\uff08\u4e5f\u53ef\u53c2\u8003&nbsp;<a class=\"reference internal\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#search-vs-match\" style=\"color: rgb(0, 114, 170);\">search() vs. match()<\/a>&nbsp;\uff09<\/p><\/dd><\/dl><dl class=\"py function\" style=\"margin-bottom: 15px; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\"><dt id=\"re.fullmatch\"><code class=\"sig-prename descclassname\" style=\"background-color: transparent; padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\">re.<\/code><code class=\"sig-name descname\" style=\"background-color: transparent; padding: 0px 1px; font-size: 19.2px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\">fullmatch<\/code><span class=\"sig-paren\" style=\"font-size: larger;\">(<\/span><em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\">pattern<\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\">string<\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\"><span class=\"n\">flags<\/span><span class=\"o\">=<\/span><span class=\"default_value\">0<\/span><\/em><span class=\"sig-paren\" style=\"font-size: larger;\">)<\/span><a class=\"headerlink\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.fullmatch\" title=\"\u6c38\u4e45\u94fe\u63a5\u81f3\u76ee\u6807\" style=\"color: rgb(0, 114, 170); visibility: hidden; font-size: 0.8em; padding: 0px 4px;\"><\/a><\/dt><dd style=\"margin-top: 3px; margin-bottom: 0px; margin-left: 30px; hyphens: auto; line-height: 1.4;\"><p style=\"hyphens: auto; line-height: 1.4;\">\u5982\u679c\u6574\u4e2a&nbsp;<em>string<\/em>&nbsp;\u5339\u914d\u5230\u6b63\u5219\u8868\u8fbe\u5f0f\u6837\u5f0f\uff0c\u5c31\u8fd4\u56de\u4e00\u4e2a\u76f8\u5e94\u7684&nbsp;<a class=\"reference internal\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#match-objects\" style=\"color: rgb(0, 114, 170);\">\u5339\u914d\u5bf9\u8c61<\/a>&nbsp;\u3002 \u5426\u5219\u5c31\u8fd4\u56de\u4e00\u4e2a&nbsp;<code class=\"docutils literal notranslate\" style=\"background-color: rgb(236, 240, 243); padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\"><span class=\"pre\" style=\"hyphens: none;\">None<\/span><\/code>&nbsp;\uff1b\u6ce8\u610f\u8fd9\u8ddf\u96f6\u957f\u5ea6\u5339\u914d\u662f\u4e0d\u540c\u7684\u3002<\/p><div class=\"versionadded\" style=\"margin-bottom: 0px;\"><p style=\"hyphens: auto; line-height: 1.4;\"><span class=\"versionmodified added\" style=\"font-style: italic;\">3.4 \u65b0\u7248\u529f\u80fd.<\/span><\/p><\/div><\/dd><\/dl><dl class=\"py function\" style=\"margin-bottom: 15px; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\"><dt id=\"re.split\"><code class=\"sig-prename descclassname\" style=\"background-color: transparent; padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\">re.<\/code><code class=\"sig-name descname\" style=\"background-color: transparent; padding: 0px 1px; font-size: 19.2px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px;\">split<\/code><span class=\"sig-paren\" style=\"font-size: larger;\">(<\/span><em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\">pattern<\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\">string<\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\"><span class=\"n\">maxsplit<\/span><span class=\"o\">=<\/span><span class=\"default_value\">0<\/span><\/em>,&nbsp;<em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace;\"><span class=\"n\">flags<\/span><span class=\"o\">=<\/span><span class=\"default_value\">0<\/span><\/em><span class=\"sig-paren\" style=\"font-size: larger;\">)<\/span><a class=\"headerlink\" href=\"https:\/\/docs.python.org\/zh-cn\/3\/library\/re.html#re.split\" title=\"\u6c38\u4e45\u94fe\u63a5\u81f3\u76ee\u6807\" style=\"color: rgb(0, 114, 170); visibility: hidden; font-size: 0.8em; padding: 0px 4px;\"><\/a><\/dt><dd style=\"margin-top: 3px; margin-bottom: 0px; margin-left: 30px; hyphens: auto; line-height: 1.4;\"><p style=\"hyphens: auto; line-height: 1.4;\">\u7528&nbsp;<em>pattern<\/em>&nbsp;\u5206\u5f00&nbsp;<em>string<\/em>&nbsp;\u3002 \u5982\u679c\u5728&nbsp;<em>pattern<\/em>&nbsp;\u4e2d\u6355\u83b7\u5230\u62ec\u53f7\uff0c\u90a3\u4e48\u6240\u6709\u7684\u7ec4\u91cc\u7684\u6587\u5b57\u4e5f\u4f1a\u5305\u542b\u5728\u5217\u8868\u91cc\u3002\u5982\u679c&nbsp;<em>maxsplit<\/em>&nbsp;\u975e\u96f6\uff0c \u6700\u591a\u8fdb\u884c&nbsp;<em>maxsplit<\/em>&nbsp;\u6b21\u5206\u9694\uff0c \u5269\u4e0b\u7684\u5b57\u7b26\u5168\u90e8\u8fd4\u56de\u5230\u5217\u8868\u7684\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u3002<\/p><\/dd><\/dl>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6d1113b elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6d1113b\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-49d9ec5\" data-id=\"49d9ec5\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-cb1eadd elementor-widget elementor-widget-text-editor\" data-id=\"cb1eadd\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p><code class=\"sig-prename descclassname\" style=\"background-color: rgb(255, 255, 255); padding: 0px 1px; font-size: 15.44px; font-family: &quot;monospace&quot;, monospace; border-radius: 3px; color: rgb(34, 34, 34);\">re.<\/code><code class=\"sig-name descname\" style=\"background-color: rgb(255, 255, 255); padding: 0px 1px; font-size: 19.2px; font-family: &quot;monospace&quot;, monospace; font-weight: bold; border-radius: 3px; color: rgb(34, 34, 34);\">findall<\/code><span class=\"sig-paren\" style=\"font-size: larger; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\">(<\/span><em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255);\"><span class=\"n\">pattern<\/span><\/em><span style=\"color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\">,&nbsp;<\/span><em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255);\"><span class=\"n\">string<\/span><\/em><span style=\"color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\">,&nbsp;<\/span><em class=\"sig-param\" style=\"font-family: &quot;monospace&quot;, monospace; color: rgb(34, 34, 34); background-color: rgb(255, 255, 255);\"><span class=\"n\">flags<\/span><span class=\"o\">=<\/span><span class=\"default_value\">0<\/span><\/em><span class=\"sig-paren\" style=\"font-size: larger; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\">)<\/span><br><\/p><p style=\"hyphens: auto; line-height: 1.4; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\">Return all non-overlapping matches of&nbsp;<em>pattern<\/em>&nbsp;in&nbsp;<em>string<\/em>, as a list of strings or tuples. The&nbsp;<em>string<\/em>&nbsp;is scanned left-to-right, and matches are returned in the order found. Empty matches are included in the result.<\/p><p><span class=\"sig-paren\" style=\"font-size: larger; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\"><\/span><\/p><p style=\"hyphens: auto; line-height: 1.4; color: rgb(34, 34, 34); font-family: &quot;Lucida Grande&quot;, Arial, sans-serif; background-color: rgb(255, 255, 255);\">The result depends on the number of capturing groups in the pattern. If there are no groups, return a list of strings matching the whole pattern. If there is exactly one group, return a list of strings matching that group. If multiple groups are present, return a list of tuples of strings matching the groups. Non-capturing groups do not affect the form of the result.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e8f9004 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e8f9004\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d6b43a4\" data-id=\"d6b43a4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-be16270 elementor-widget elementor-widget-text-editor\" data-id=\"be16270\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>\u00a0<\/p>\n<h2 style=\"margin-top: 0px; font-family: 'Roboto Slab', ff-tisa-web-pro, Georgia, Arial, sans-serif; font-size: 24px; color: #404040; background-color: #fcfcfc;\"><a class=\"toc-backref\" style=\"color: #404040; cursor: pointer;\" href=\"https:\/\/hellopython.readthedocs.io\/zh_CN\/latest\/re_module.html#id26\">\u5b57\u7b26\u4e32\u5206\u5272<\/a><\/h2>\n<p style=\"line-height: 24px; margin-bottom: 24px; color: #404040; font-family: Lato, proxima-nova, 'Helvetica Neue', Arial, sans-serif; background-color: #fcfcfc;\">\u4f7f\u7528re.split(pattern, string, maxsplit=0, flags=0)\u8fdb\u884c\u5b57\u7b26\u5206\u5272:<\/p>\n<h2><a class=\"toc-backref\" href=\"https:\/\/hellopython.readthedocs.io\/zh_CN\/latest\/re_module.html#id27\">\u5b57\u7b26\u4e32\u66ff\u6362<\/a><\/h2>\n<p>\u4f7f\u7528re.sub(pattern, repl, string, count=0, flags=0)\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u66ff\u6362:<\/p>\n<h2><a class=\"toc-backref\" href=\"https:\/\/hellopython.readthedocs.io\/zh_CN\/latest\/re_module.html#id28\">\u5b57\u7b26\u8f6c\u4e49<\/a><\/h2>\n<p>\u4f7f\u7528re.escape\u5c06\u6240\u6709\u5b57\u7b26\u8f6c\u4e49:<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-bb94b18 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"bb94b18\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ea028d4\" data-id=\"ea028d4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-32acc2c elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"32acc2c\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c4f62a3\" data-id=\"c4f62a3\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-78cbb11 elementor-widget elementor-widget-image\" data-id=\"78cbb11\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/www.pexels.com\/\">\n\t\t\t\t\t\t\t<img src=\"https:\/\/images.pexels.com\/photos\/2469122\/pexels-photo-2469122.jpeg?cs=srgb&amp;dl=pexels-cliford-mervil-2469122.jpg&amp;fm=jpg\" title=\"\" alt=\"\" \/>\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>\u6b63\u5219\u8868\u8fbe\u5f0f . \u70b9\u53f7\uff0c\u5728\u9ed8\u8ba4\u6a21\u5f0f\u4e0b\uff0c\u5339\u914d\u9664\u6362\u884c\u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26\u3002\u5982\u679c DOTALL \u6807\u5fd7\u88ab\u6307\u5b9a, \u5219\u5339\u914d\u5305\u62ec\u6362\u884c &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2021\/12\/15\/python-2\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">python \u6b63\u5219\u8868\u8fbe\u5f0f\u548cre\u6a21\u5757<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/214"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=214"}],"version-history":[{"count":25,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":244,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/214\/revisions\/244"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}