{"id":528,"date":"2023-09-16T15:39:10","date_gmt":"2023-09-16T07:39:10","guid":{"rendered":""},"modified":"2023-09-17T00:42:12","modified_gmt":"2023-09-16T16:42:12","slug":"%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e5%8c%b9%e9%85%8d%e5%bc%80%e5%a4%b4%e5%92%8c%e7%bb%93%e5%b0%be%ef%bc%88%e3%80%81%e3%80%81%e6%8c%87%e5%ae%9a%e5%ad%97%e7%ac%a6%ef%bc%89","status":"publish","type":"post","link":"https:\/\/mushiming.com\/528.html","title":{"rendered":"\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e\uff08^\u3001$\u3001[^\u6307\u5b9a\u5b57\u7b26]\uff09"},"content":{"rendered":"

1. \u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e<\/h2>\n\n\n\n\n\n\n
\u4ee3\u7801<\/th>\n\u529f\u80fd<\/th>\n<\/tr>\n<\/thead>\n
^<\/td>\n\u5339\u914d\u5b57\u7b26\u4e32\u5f00\u5934<\/td>\n<\/tr>\n
$<\/td>\n\u5339\u914d\u5b57\u7b26\u4e32\u7ed3\u5c3e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u793a\u4f8b1\uff1a^<\/h3>\n

\u9700\u6c42\uff1a\u5339\u914d\u4ee5\u6570\u5b57\u5f00\u5934\u7684\u6570\u636e<\/p>\n

import re\n\n# \u5339\u914d\u4ee5\u6570\u5b57\u5f00\u5934\u7684\u6570\u636e\nmatch_obj = re.match(\"^\\d.*\", \"1hello_world!\")\nprint(match_obj)\nif match_obj:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n\nmatch_obj2 = re.match(\"^\\d.*\", \"hello_world!\")\nprint(match_obj2)\nif match_obj2:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj2.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n<\/code><\/pre>\n

\u8fd0\u884c\u7ed3\u679c:<\/p>\n

\"\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e\uff08^\u3001$\u3001[^\u6307\u5b9a\u5b57\u7b26]\uff09<\/p>\n

\u793a\u4f8b2\uff1a$<\/h3>\n

\u9700\u6c42: \u5339\u914d\u4ee5\u6570\u5b57\u7ed3\u5c3e\u7684\u6570\u636e<\/p>\n

import re\n\n# \u5339\u914d\u4ee5\u6570\u5b57\u7ed3\u5c3e\u7684\u6570\u636e\nmatch_obj = re.match(\".*\\d$\", \"hello_world5\")\nprint(match_obj)\nif match_obj:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n\nmatch_obj2 = re.match(\".*\\d$\", \"hello_world\")\nprint(match_obj2)\nif match_obj2:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj2.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n<\/code><\/pre>\n

\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n

\"\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e\uff08^\u3001$\u3001[^\u6307\u5b9a\u5b57\u7b26]\uff09<\/p>\n

\u793a\u4f8b3\uff1a^ \u548c $<\/h3>\n

\u9700\u6c42: \u5339\u914d\u4ee5\u6570\u5b57\u5f00\u5934\uff0c\u4e2d\u95f4\u5185\u5bb9\u4e0d\u7ba1\uff0c\u4ee5\u6570\u5b57\u7ed3\u5c3e<\/p>\n

import re\n\nmatch_obj = re.match(\"^\\d.*\\d$\", \"4hello_world4\")\nprint(match_obj)\nif match_obj:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n<\/code><\/pre>\n

\u8fd0\u884c\u7ed3\u679c:<\/p>\n

\"\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e\uff08^\u3001$\u3001[^\u6307\u5b9a\u5b57\u7b26]\uff09<\/p>\n

2.\u9664\u4e86\u6307\u5b9a\u5b57\u7b26\u4ee5\u5916\u90fd\u5339\u914d<\/h3>\n

[^\u6307\u5b9a\u5b57\u7b26]: \u8868\u793a\u9664\u4e86\u6307\u5b9a\u5b57\u7b26\u90fd\u5339\u914d<\/p>\n

\u9700\u6c42: \u7b2c\u4e00\u4e2a\u5b57\u7b26\u9664\u4e86aeiou\u7684\u5b57\u7b26\u90fd\u5339\u914d<\/p>\n

import re\n\nmatch_obj = re.match(\"[^abc]\", \"ILoveChina\")\nif match_obj:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n\nmatch_obj2 = re.match(\"[^abc]\", \"aaa\")\nif match_obj2:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj2.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n\nmatch_obj3 = re.match(\"[^abc].*\", \"China\")\nif match_obj3:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj3.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n\nmatch_obj4 = re.match(\"[^abc]*\", \"China\")\nif match_obj4:\n    # \u83b7\u53d6\u5339\u914d\u7ed3\u679c\n    print(match_obj4.group())\nelse:\n    print(\"\u5339\u914d\u5931\u8d25\")\n<\/code><\/pre>\n

\u6267\u884c\u7ed3\u679c\uff1a<\/p>\n

\"\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e\uff08^\u3001$\u3001[^\u6307\u5b9a\u5b57\u7b26]\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e\uff08^\u3001$\u3001[^\u6307\u5b9a\u5b57\u7b26]\uff09\u6b63\u5219\u8868\u8fbe\u5f0f\u4e4b\u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e1.\u5339\u914d\u5f00\u5934\u548c\u7ed3\u5c3e\u4ee3\u7801\t\t\t\u529f\u80fd\t\t^\t\t\t\u5339\u914d\u5b57\u7b26\u4e32\u5f00...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/528"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=528"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/528\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}