{"id":1188,"date":"2022-06-11T18:02:19","date_gmt":"2022-06-11T10:02:19","guid":{"rendered":"https:\/\/www.mapleriver.cn\/?p=1188"},"modified":"2022-06-25T16:05:33","modified_gmt":"2022-06-25T08:05:33","slug":"%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/www.mapleriver.cn\/?p=1188","title":{"rendered":"\u6b63\u5219\u8868\u8fbe\u5f0f"},"content":{"rendered":"<p>&emsp;&emsp;\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u7531\u5b57\u7b26\u6784\u6210\u7684\u8868\u8fbe\u5f0f\uff0c\u6bcf\u4e2a\u5b57\u7b26\u4ee3\u8868\u4e00\u4e2a\u89c4\u5219\uff0c\u8868\u8fbe\u5f0f\u4e2d\u7684\u5b57\u7b26\u5206\u4e3a\u4e24\u79cd\u7c7b\u578b\uff1a\u666e\u901a\u5b57\u7b26\u548c\u5143\u5b57\u7b26\u3002\u666e\u901a\u5b57\u7b26\u662f\u6307\u5b57\u9762\u542b\u4e49\u4e0d\u53d8\u7684\u5b57\u7b26\uff0c\u6309\u7167\u5b8c\u5168\u5339\u914d\u7684\u65b9\u5f0f\u5339\u914d\u6587\u672c\uff0c\u800c\u5143\u5b57\u7b26\u5177\u6709\u7279\u6b8a\u7684\u542b\u4e49\uff0c\u4ee3\u8868\u4e00\u7c7b\u5b57\u7b26\u3002<br \/>\n&emsp;&emsp;\u628a\u6587\u672c\u770b\u4f5c\u662f\u5b57\u7b26\u6d41\uff0c\u6bcf\u4e2a\u5b57\u7b26\u653e\u5728\u4e00\u4e2a\u4f4d\u7f6e\u4e0a\uff0c\u4f8b\u5982\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f \u201cRoom\\d\\d\\d\u201d\uff0c\u524d\u9762\u56db\u4e2a\u5b57\u7b26Room\u662f\u666e\u901a\u5b57\u7b26\uff0c\u540e\u9762\u7684\u5b57\u7b26\\\u662f\u8f6c\u4e49\u5b57\u7b26\uff0c\u548c\u540e\u9762\u7684\u5b57\u7b26d\u7ec4\u6210\u4e00\u4e2a\u5143\u5b57\u7b26\\d\uff0c\u8868\u793a\u8be5\u4f4d\u7f6e\u4e0a\u6709\u4efb\u610f\u4e00\u4e2a\u6570\u5b57\u3002<br \/>\n<a href=\"https:\/\/www.mapleriver.cn\/wp-content\/uploads\/2022\/06\/patternNormal.png\"><img decoding=\"async\" src=\"https:\/\/www.mapleriver.cn\/wp-content\/uploads\/2022\/06\/patternNormal-300x115.png\" alt=\"\" \/><\/a><br \/>\n&emsp;&emsp;\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u8bed\u8a00\u6765\u63cf\u8ff0\u662f\uff1a\u6b63\u5219\u8868\u8fbe\u5f0f \u201cRoom\\d\\d\\d\u201d\u5171\u6355\u83b77\u4e2a\u5b57\u7b26\uff0c\u8868\u793a\u201c\u4ee5Room\u5f00\u5934\u3001\u4ee5\u4e09\u4e2a\u6570\u5b57\u7ed3\u5c3e\u201d\u7684\u4e00\u7c7b\u5b57\u7b26\u4e32\uff0c\u6211\u4eec\u628a\u8fd9\u4e00\u7c7b\u5b57\u7b26\u4e32\u79f0\u4f5c\u4e00\u4e2a\u6a21\u5f0f\uff08Pattern\uff09\uff0c\u4e5f\u79f0\u4f5c\u662f\u4e00\u4e2a\u6b63\u5219\u3002<\/p>\n<h5>1.\u8f6c\u4e49\u5b57\u7b26<\/h5>\n<p>&emsp;&emsp;\u8f6c\u4e49\u5b57\u7b26\u662f\\\uff0c\u628a\u666e\u901a\u5b57\u7b26\u8f6c\u4e49\u4e3a\u5177\u6709\u7279\u6b8a\u542b\u4e49\u7684\u5143\u5b57\u7b26\uff0c\u5e38\u7528\u7684\u8f6c\u4e49\u5b57\u7b26\u6709\uff1a<\/p>\n<pre><code>\\t\uff1a\u6c34\u5e73\u5236\u8868\u7b26\n\\v\uff1a\u5782\u76f4\u5236\u8868\u7b26\n\\r\uff1a\u56de\u8f66\n\\n\uff1a\u6362\u884c\n\\\\\uff1a\u8868\u793a\u5b57\u7b26 \\\uff0c\u4e5f\u5c31\u8bf4\uff0c\u628a\u8f6c\u4e49\u5b57\u7b26 \\ \u8f6c\u4e49\u4e3a\u666e\u901a\u7684\u5b57\u7b26 \\\n\\&quot;\uff1a\u8868\u793a\u5b57\u7b26 &quot;\uff0c\u5728C#\u4e2d\uff0c\u53cc\u5f15\u53f7\u7528\u4e8e\u5b9a\u4e49\u5b57\u7b26\u4e32\uff0c\u5b57\u7b26\u4e32\u5305\u542b\u7684\u53cc\u5f15\u53f7\u7528 \\&quot; \u6765\u8868\u793a<\/code><\/pre>\n<h5>2.\u5b57\u7b26\u7c7b<\/h5>\n<p>&emsp;&emsp;\u5728\u8fdb\u884c\u6b63\u5219\u5339\u914d\u65f6\uff0c\u628a\u8f93\u5165\u6587\u672c\u770b\u4f5c\u662f\u6709\u987a\u5e8f\u7684\u5b57\u7b26\u6d41\uff0c\u5b57\u7b26\u7c7b\u5143\u5b57\u7b26\u5339\u914d\u7684\u5bf9\u8c61\u662f\u5b57\u7b26\uff0c\u5e76\u4f1a\u6355\u83b7\u5b57\u7b26\u3002\u6240\u8c13\u6355\u83b7\u5b57\u7b26\u662f\u6307\uff0c\u4e00\u4e2a\u5143\u5b57\u7b26\u6355\u83b7\u7684\u5b57\u7b26\uff0c\u4e0d\u4f1a\u88ab\u5176\u4ed6\u5143\u5b57\u7b26\u5339\u914d\uff0c\u540e\u7eed\u7684\u5143\u5b57\u7b26\u53ea\u80fd\u4ece\u5269\u4e0b\u7684\u6587\u672c\u4e2d\u91cd\u65b0\u5339\u914d\u3002<\/p>\n<pre><code>[ char_group]\uff1a\u5339\u914d\u5b57\u7b26\u7ec4\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26\n[^char_group]\uff1a\u5339\u914d\u9664\u5b57\u7b26\u7ec4\u4e4b\u5916\u7684\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26\n[first-last]\uff1a\u5339\u914d\u4ecefirst\u5230last\u7684\u5b57\u7b26\u8303\u56f4\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26\uff0c\u5b57\u7b26\u8303\u56f4\u5305\u62ecfirst\u548clast\u3002\n.   \uff1a\u901a\u914d\u7b26\uff0c\u5339\u914d\u9664\\n\u4e4b\u5916\u7684\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26\n\\w\uff1a\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u5355\u8bcd\uff08word\uff09\u5b57\u7b26\uff0c\u5355\u8bcd\u5b57\u7b26\u901a\u5e38\u662f\u6307A-Z\u3001a-z\u548c0-9\n\\W\uff1a\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u975e\u5355\u8bcd\u5b57\u7b26\uff0c\u662f\u6307\u9664A-Z\u3001a-z\u548c0-9\u4e4b\u5916\u7684\u5b57\u7b26\n\\s\uff1a\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u7a7a\u767d\u5b57\u7b26\n\\S\uff1a\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u975e\u7a7a\u767d\u5b57\u7b26\n\\d\uff1a\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u6570\u5b57\u5b57\u7b26\n\\D\uff1a\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u975e\u6570\u5b57\u5b57\u7b26\nx|y \u5339\u914dx\u6216y\u3002\u4f8b\u5982\uff0c\u2018z|food\u2019\u80fd\u5339\u914d\u201cz\u201d\u6216\u201cfood\u201d\u3002\u2018(z|f)ood\u2019\u5219\u5339\u914d\u201czood\u201d\u6216\u201cfood\u201d<\/code><\/pre>\n<p>&emsp;&emsp;\u6ce8\u610f\uff0c\u8f6c\u4e49\u5b57\u7b26\u4e5f\u5c5e\u4e8e\u5b57\u7b26\u7c7b\u5143\u5b57\u7b26\uff0c\u5728\u8fdb\u884c\u6b63\u5219\u5339\u914d\u65f6\uff0c\u4e5f\u4f1a\u6355\u83b7\u5b57\u7b26\u3002<\/p>\n<h5>3.\u5b9a\u4f4d\u7b26<\/h5>\n<p>&emsp;&emsp;\u5b9a\u4f4d\u7b26\u5339\u914d\uff08\u6216\u6355\u83b7\uff09\u7684\u5bf9\u8c61\u662f\u4f4d\u7f6e\uff0c\u5b83\u6839\u636e\u5b57\u7b26\u7684\u4f4d\u7f6e\u6765\u5224\u65ad\u6a21\u5f0f\u5339\u914d\u662f\u5426\u6210\u529f\uff0c\u5b9a\u4f4d\u7b26\u4e0d\u4f1a\u6355\u83b7\u5b57\u7b26\uff0c\u662f\u96f6\u5bbd\u7684\uff08\u5bbd\u5ea6\u4e3a0\uff09\uff0c\u5e38\u7528\u7684\u5b9a\u4f4d\u7b26\u6709\uff1a<\/p>\n<pre><code>^\uff1a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\uff1b\u5728\u591a\u884c\u6a21\u5f0f\u4e0b\uff0c\u5339\u914d\u6bcf\u884c\u7684\u5f00\u59cb\u4f4d\u7f6e\uff1b\n$\uff1a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\u4f4d\u7f6e\uff0c\u6216 \u5b57\u7b26\u4e32\u7ed3\u5c3e\u7684\\n\u4e4b\u524d\u7684\u4f4d\u7f6e\uff1b\u5728\u591a\u884c\u6a21\u5f0f\u4e0b\uff0c\u5339\u914d\u6bcf\u884c\u7ed3\u675f\u4e4b\u524d\u7684\u4f4d\u7f6e\uff0c\u6216\u8005\u6bcf\u884c\u7ed3\u5c3e\u7684\\n\u4e4b\u524d\u7684\u4f4d\u7f6e\u3002\n\\A\uff1a\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\uff1b\n\\Z\uff1a\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\u4f4d\u7f6e\uff0c\u6216 \u5b57\u7b26\u4e32\u7ed3\u5c3e\u7684\\n\u4e4b\u524d\u7684\u4f4d\u7f6e\uff1b\n\\z\uff1a\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\u4f4d\u7f6e\uff1b\n\\G\uff1a\u5339\u914d\u4e0a\u4e00\u4e2a\u5339\u914d\u7ed3\u675f\u7684\u4f4d\u7f6e\uff1b\n\\b\uff1a\u5339\u914d\u4e00\u4e2a\u5355\u8bcd\u7684\u5f00\u59cb\u6216\u7ed3\u675f\u7684\u4f4d\u7f6e\uff1b\n\\B\uff1a\u5339\u914d\u4e00\u4e2a\u5355\u8bcd\u7684\u4e2d\u95f4\u4f4d\u7f6e\uff1b<\/code><\/pre>\n<h5>4.\u91cf\u8bcd\u3001\u8d2a\u5a6a\u548c\u61d2\u60f0<\/h5>\n<p>&emsp;&emsp;\u91cf\u8bcd\u662f\u6307\u9650\u5b9a\u524d\u9762\u7684\u4e00\u4e2a\u6b63\u5219\u51fa\u73b0\u7684\u6b21\u6570\uff0c\u91cf\u8bcd\u5206\u4e3a\u4e24\u79cd\u6a21\u5f0f\uff1a\u8d2a\u5a6a\u6a21\u5f0f\u548c\u61d2\u60f0\u6a21\u5f0f\uff0c\u8d2a\u5a6a\u6a21\u5f0f\u662f\u6307\u5339\u914d\u5c3d\u53ef\u80fd\u591a\u7684\u5b57\u7b26\uff0c\u800c\u61d2\u60f0\u6a21\u5f0f\u662f\u6307\u5339\u914d\u5c3d\u53ef\u80fd\u5c11\u7684\u5b57\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u91cf\u8bcd\u5904\u4e8e\u8d2a\u5a6a\u6a21\u5f0f\uff0c\u5728\u91cf\u8bcd\u7684\u540e\u9762\u52a0\u4e0a?\u6765\u542f\u7528\u61d2\u60f0\u6a21\u5f0f\u3002<\/p>\n<pre><code>*\uff1a\u51fa\u73b00\u6b21\u6216\u591a\u6b21\n+\uff1a\u51fa\u73b01\u6b21\u6216\u591a\u6b21\n?\uff1a\u51fa\u73b00\u6b21\u62161\u6b21\n{n}\uff1a\u51fa\u73b0n\u6b21\n{n,}\uff1a\u51fa\u73b0\u81f3\u5c11n\u6b21\n{n,m}\uff1a\u51fa\u73b0n\u5230m\u6b21<\/code><\/pre>\n<p>&emsp;&emsp;\u6ce8\u610f\uff0c\u51fa\u73b0\u591a\u6b21\u662f\u6307\u524d\u9762\u7684\u5143\u5b57\u7b26\u51fa\u73b0\u591a\u6b21\uff0c\u4f8b\u5982\uff0c\\d{2} \u7b49\u4ef7\u4e8e \\d\\d\uff0c\u53ea\u662f\u51fa\u73b0\u4e24\u4e2a\u6570\u5b57\uff0c\u5e76\u4e0d\u8981\u6c42\u4e24\u4e2a\u6570\u5b57\u662f\u76f8\u540c\u7684\u3002\u8981\u8868\u793a\u76f8\u540c\u7684\u4e24\u4e2a\u6570\u5b57\uff0c\u5fc5\u987b\u4f7f\u7528\u5206\u7ec4\u6765\u5b9e\u73b0\u3002<br \/>\n<a href=\"https:\/\/www.mapleriver.cn\/wp-content\/uploads\/2022\/06\/lazygreedy.png\"><img decoding=\"async\" src=\"https:\/\/www.mapleriver.cn\/wp-content\/uploads\/2022\/06\/lazygreedy.png\" alt=\"\" \/><\/a><\/p>\n<h5>5.\u5206\u7ec4\u548c\u6355\u83b7\u5b57\u7b26<\/h5>\n<p>&emsp;&emsp;()  \u62ec\u53f7\u4e0d\u4ec5\u786e\u5b9a\u8868\u8fbe\u5f0f\u7684\u8303\u56f4\uff0c\u8fd8\u521b\u5efa\u5206\u7ec4\uff0c()\u5185\u7684\u8868\u8fbe\u5f0f\u5c31\u662f\u4e00\u4e2a\u5206\u7ec4\uff0c\u5f15\u7528\u5206\u7ec4\u8868\u793a\u4e24\u4e2a\u5206\u7ec4\u5339\u914d\u7684\u6587\u672c\u662f\u5b8c\u5168\u76f8\u540c\u7684\u3002\u5b9a\u4e49\u4e00\u4e2a\u5206\u7ec4\u7684\u57fa\u672c\u8bed\u6cd5\uff1a<\/p>\n<pre><code>(pattern)    \u5339\u914d pattern \u5e76\u83b7\u53d6\u8fd9\u4e00\u5339\u914d<\/code><\/pre>\n<p>&emsp;&emsp;\u8be5\u7c7b\u578b\u7684\u5206\u7ec4\u4f1a\u6355\u83b7\u5b57\u7b26\uff0c\u6240\u8c13\u6355\u83b7\u5b57\u7b26\u662f\u6307\uff1a\u4e00\u4e2a\u5143\u5b57\u7b26\u6355\u83b7\u7684\u5b57\u7b26\uff0c\u4e0d\u4f1a\u88ab\u5176\u4ed6\u5143\u5b57\u7b26\u5339\u914d\uff0c\u540e\u7eed\u7684\u5143\u5b57\u7b26\u53ea\u80fd\u4ece\u5269\u4e0b\u7684\u6587\u672c\u4e2d\u91cd\u65b0\u5339\u914d\u3002<\/p>\n<h6>\u5206\u7ec4\u7f16\u53f7\u548c\u547d\u540d<\/h6>\n<p>&emsp;&emsp;\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e2a\u5206\u7ec4\u81ea\u52a8\u5206\u914d\u4e00\u4e2a\u7ec4\u53f7\uff0c\u89c4\u5219\u662f\uff1a\u4ece\u5de6\u5411\u53f3\uff0c\u6309\u5206\u7ec4\u5de6\u62ec\u53f7\u7684\u51fa\u73b0\u987a\u5e8f\u8fdb\u884c\u7f16\u53f7\uff0c\u7b2c\u4e00\u4e2a\u5206\u7ec4\u7684\u7ec4\u53f7\u4e3a1\uff0c\u7b2c\u4e8c\u4e2a\u4e3a2\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002\u4e5f\u53ef\u4ee5\u4e3a\u5206\u7ec4\u6307\u5b9a\u540d\u79f0\uff0c\u8be5\u5206\u7ec4\u79f0\u4f5c\u547d\u540d\u5206\u7ec4\uff0c\u547d\u540d\u5206\u7ec4\u4e5f\u4f1a\u88ab\u81ea\u52a8\u7f16\u53f7\uff0c\u7f16\u53f7\u4ece1\u5f00\u59cb\uff0c\u9010\u4e2a\u52a01\uff0c\u4e3a\u5206\u7ec4\u6307\u5b9a\u540d\u79f0\u7684\u8bed\u6cd5\u662f\uff1a<\/p>\n<pre><code>(?&lt; name &gt; pattern)<\/code><\/pre>\n<p>&emsp;&emsp;\u901a\u5e38\u6765\u8bf4\uff0c\u5206\u7ec4\u5206\u4e3a\u547d\u540d\u5206\u7ec4\u548c\u7f16\u53f7\u5206\u7ec4\uff0c\u5f15\u7528\u5206\u7ec4\u7684\u65b9\u5f0f\u6709\uff1a<\/p>\n<ul>\n<li>\u901a\u8fc7\u5206\u7ec4\u540d\u79f0\u6765\u5f15\u7528\u5206\u7ec4\uff1a\\\\<name><\/li>\n<li>\u901a\u8fc7\u5206\u7ec4\u7f16\u53f7\u6765\u5f15\u7528\u5206\u7ec4\uff1a\\number<\/li>\n<\/ul>\n<p>&emsp;&emsp;\u6ce8\u610f\uff0c\u5206\u7ec4\u53ea\u80fd\u540e\u5411\u5f15\u7528\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u4ece\u6b63\u5219\u8868\u8fbe\u5f0f\u6587\u672c\u7684\u5de6\u8fb9\u5f00\u59cb\uff0c\u5206\u7ec4\u5fc5\u987b\u5148\u5b9a\u4e49\uff0c\u7136\u540e\u624d\u80fd\u5728\u5b9a\u4e49\u4e4b\u540e\u9762\u5f15\u7528\u3002<\/p>\n<p>&emsp;&emsp;\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u91cc\u5f15\u7528\u5206\u7ec4\u7684\u8bed\u6cd5\u4e3a\u201c\\number\u201d\uff0c\u6bd4\u5982\u201c\\1\u201d\u4ee3\u8868\u4e0e\u5206\u7ec41 \u5339\u914d\u7684\u5b50\u4e32\uff0c\u201c\\2\u201d\u4ee3\u8868\u4e0e\u5206\u7ec42 \u5339\u914d\u7684\u5b57\u4e32\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002<\/p>\n<p>&emsp;&emsp;\u4f8b\u5982\uff0c\u5bf9\u4e8e <code>&quot;&lt;(.*?)&gt;.*?&lt;\/\\1&gt;&quot;<\/code> \u53ef\u4ee5\u5339\u914d <code>&lt;h2&gt;valid&lt;\/h2&gt;<\/code>\uff0c\u5728\u5f15\u7528\u5206\u7ec4\u65f6\uff0c\u5206\u7ec4\u5bf9\u5e94\u7684\u6587\u672c\u662f\u5b8c\u5168\u76f8\u540c\u7684\u3002<\/p>\n<h6>\u5206\u7ec4\u6784\u9020\u5668<\/h6>\n<pre><code>(pattern)\uff1a\u6355\u83b7\u5339\u914d\u7684\u5b50\u8868\u8fbe\u5f0f\uff0c\u5e76\u4e3a\u5206\u7ec4\u5206\u914d\u4e00\u4e2a\u7ec4\u53f7\n(?&lt; name &gt; pattern)\uff1a\u628a\u5339\u914d\u7684\u5b50\u8868\u8fbe\u5f0f\u6355\u83b7\u5230\u547d\u540d\u7684\u5206\u7ec4\u4e2d\n(?:pattern)\uff1a\u975e\u6355\u83b7\u7684\u5206\u7ec4\uff0c\u5e76\u672a\u5206\u7ec4\u5206\u914d\u4e00\u4e2a\u7ec4\u53f7(\u4ecd\u4f1a\u5339\u914d\uff0c\u4f46\u4e0d\u4f1a\u5206\u914d\u7ec4\u53f7)\n(?&gt; pattern)\uff1a\u8d2a\u5a6a\u5206\u7ec4<\/code><\/pre>\n<p>&emsp;&emsp;\u8d2a\u5a6a\u5206\u7ec4\u4e5f\u79f0\u4f5c\u975e\u56de\u6eaf\u5206\u7ec4\uff0c\u8be5\u5206\u7ec4\u7981\u7528\u4e86\u56de\u6eaf\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u5f15\u64ce\u5c06\u5c3d\u53ef\u80fd\u591a\u5730\u5339\u914d\u8f93\u5165\u6587\u672c\u4e2d\u7684\u5b57\u7b26\u3002\u5982\u679c\u65e0\u6cd5\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u5339\u914d\uff0c\u5219\u4e0d\u4f1a\u56de\u6eaf\u5c1d\u8bd5\u8fdb\u884c\u5176\u4ed6\u6a21\u5f0f\u5339\u914d\u3002<\/p>\n<h5>6.\u96f6\u5bbd\u65ad\u8a00<\/h5>\n<p>&emsp;&emsp;\u96f6\u5bbd\uff1a<br \/>\n&emsp;&emsp;\u6307\u7684\u662f\u5b83\u4eec\u4e0d\u4e0e\u4efb\u4f55\u5b57\u7b26\u76f8\u5339\u914d\uff0c\u800c\u5339\u914d\u4e00\u4e2a\u4f4d\u7f6e\u3002<br \/>\n&emsp;&emsp;\u65ad\u8a00\uff1a<br \/>\n&emsp;&emsp;\u6307\u7684\u662f\u4e00\u4e2a\u5224\u65ad\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\u53ea\u6709\u5f53\u65ad\u8a00\u4e3a\u771f\u65f6\u624d\u4f1a\u7ee7\u7eed\u8fdb\u884c\u5339\u914d\u3002<br \/>\n&emsp;&emsp;\u6b63\u5219\u8868\u8fbe\u5f0f\u628a\u6587\u672c\u770b\u4f5c\u4ece\u5de6\u5411\u53f3\u7684\u5b57\u7b26\u6d41\uff0c\u5411\u53f3\u53eb\u505a\u540e\u5411\uff08Look behind\uff09\uff0c\u5411\u5de6\u53eb\u505a\u524d\u5411\uff08Look ahead\uff09\u3002\u5bf9\u4e8e\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u53ea\u6709\u5f53\u5339\u914d\u5230\u6307\u5b9a\u7684\u6a21\u5f0f\uff08Pattern\uff09\u65f6\uff0c\u65ad\u8a00\u4e3aTrue\uff0c\u53eb\u505a\u80af\u5b9a\u5f0f\uff0c\u628a\u4e0d\u5339\u914d\u6a21\u5f0f\u4e3aTrue\uff0c\u53eb\u505a\u5426\u5b9a\u5f0f\u3002<\/p>\n<pre><code>(?= pattern)\uff1a\u524d\u5411\u3001\u80af\u5b9a\u65ad\u8a00\n(?! pattern)\uff1a\u524d\u5411\u3001\u5426\u5b9a\u65ad\u8a00\n(?&lt;= pattern)\uff1a\u540e\u5411\u3001\u80af\u5b9a\u65ad\u8a00\n(?&lt;! pattern)\uff1a\u540e\u5411\u3001\u5426\u5b9a\u65ad\u8a00<\/code><\/pre>\n<h6>\u524d\u5411\u80af\u5b9a\u65ad\u8a00<\/h6>\n<p>&emsp;&emsp;\u524d\u5411\u80af\u5b9a\u65ad\u8a00\u5b9a\u4e49\u4e00\u4e2a\u6a21\u5f0f\u5fc5\u987b\u5b58\u5728\u4e8e\u6587\u672c\u7684\u672b\u5c3e\uff08\u6216\u53f3\u4fa7\uff09\uff0c\u4f46\u662f\u8be5\u6a21\u5f0f\u5339\u914d\u7684\u5b50\u4e32\u4e0d\u4f1a\u51fa\u73b0\u5728\u5339\u914d\u7684\u7ed3\u679c\u4e2d\uff0c\u524d\u5411\u65ad\u8a00\u901a\u5e38\u51fa\u73b0\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u53f3\u4fa7\uff0c\u8868\u793a\u6587\u672c\u7684\u53f3\u4fa7\u5fc5\u987b\u6ee1\u8db3\u7279\u5b9a\u7684\u6a21\u5f0f\u3002<br \/>\n&emsp;&emsp;\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre><code>\\b\\w+(?=\\sis\\b)<\/code><\/pre>\n<p>\u5bf9\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u5206\u6790\uff1a<\/p>\n<ul>\n<li>\\b\uff1a\u8868\u793a\u5355\u8bcd\u7684\u8fb9\u754c<\/li>\n<li>\\w+\uff1a\u8868\u793a\u5355\u8bcd\u81f3\u5c11\u51fa\u73b0\u4e00\u6b21<\/li>\n<li>(?=\\sis\\b)\uff1a\u524d\u5411\u80af\u5b9a\u65ad\u8a00\uff0c\\s \u8868\u793a\u4e00\u4e2a\u7a7a\u767d\u5b57\u7b26\uff0c is \u662f\u666e\u901a\u5b57\u7b26\uff0c\u5b8c\u5168\u5339\u914d\uff0c\\b \u662f\u5355\u8bcd\u7684\u8fb9\u754c\u3002<\/li>\n<\/ul>\n<p>&emsp;&emsp;\u4ece\u5206\u6790\u4e2d\uff0c\u53ef\u4ee5\u5f97\u51fa\uff0c\u5339\u914d\u8be5\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u6587\u672c\u4e2d\u5fc5\u987b\u5305\u542b is \u5355\u8bcd\uff0cis\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u5355\u8bcd\uff0c\u4e0d\u662f\u67d0\u4e00\u4e2a\u5355\u8bcd\u7684\u4e00\u4e2a\u90e8\u5206\u3002<\/p>\n<pre><code>Sunday is a weekend day \u5339\u914d\u8be5\u6b63\u5219\uff0c\u5339\u914d\u7684\u503c\u662fSunday\uff0c\u800cThe island has beautiful birds \u4e0d\u5339\u914d\u8be5\u6b63\u5219\u3002<\/code><\/pre>\n<h6>\u540e\u5411\u80af\u5b9a\u65ad\u8a00<\/h6>\n<p>&emsp;&emsp;\u540e\u5411\u80af\u5b9a\u65ad\u8a00\u5b9a\u4e49\u4e00\u4e2a\u6a21\u5f0f\u5fc5\u987b\u5b58\u5728\u4e8e\u6587\u672c\u7684\u5f00\u59cb\uff08\u6216\u5de6\u4fa7\uff09\uff0c\u4f46\u662f\u8be5\u6a21\u5f0f\u5339\u914d\u7684\u5b50\u4e32\u4e0d\u4f1a\u51fa\u73b0\u5728\u5339\u914d\u7684\u7ed3\u679c\u4e2d\uff0c\u540e\u5411\u65ad\u8a00\u901a\u5e38\u51fa\u73b0\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5de6\u4fa7\uff0c\u8868\u793a\u6587\u672c\u7684\u5de6\u4fa7\u5fc5\u987b\u6ee1\u8db3\u7279\u5b9a\u7684\u6a21\u5f0f\u3002<br \/>\n&emsp;&emsp;\u8fd8\u662f\u4e3e\u4e2a\u4f8b\u5b50<\/p>\n<pre><code>(?&lt;=\\b20)\\d{2}\\b<\/code><\/pre>\n<p>\u5bf9\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u5206\u6790\uff1a<\/p>\n<ul>\n<li>(?&lt;=\\b20)\uff1a\u540e\u5411\u65ad\u8a00\uff0c\\b\u8868\u793a\u5355\u8bcd\u7684\u5f00\u59cb\uff0c20\u662f\u666e\u901a\u5b57\u7b26<\/li>\n<li>\\d{2}\uff1a\u8868\u793a\u4e24\u4e2a\u6570\u5b57\uff0c\u6570\u5b57\u4e0d\u8981\u6c42\u76f8\u540c<\/li>\n<li>\\b\uff1a\u5355\u8bcd\u7684\u8fb9\u754c<\/li>\n<\/ul>\n<p>&emsp;&emsp;\u8be5\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u7684\u6587\u672c\u5177\u5907\u7684\u6a21\u5f0f\u662f\uff1a\u6587\u672c\u4ee520\u5f00\u5934\u3001\u4ee5\u4e24\u4e2a\u6570\u5b57\u7ed3\u5c3e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&emsp;&emsp;\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u7531\u5b57\u7b26\u6784\u6210\u7684\u8868\u8fbe\u5f0f\uff0c\u6bcf\u4e2a\u5b57\u7b26\u4ee3\u8868\u4e00\u4e2a\u89c4\u5219\uff0c\u8868\u8fbe\u5f0f\u4e2d\u7684\u5b57\u7b26\u5206\u4e3a\u4e24\u79cd\u7c7b\u578b\uff1a\u666e\u901a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-1188","post","type-post","status-publish","format-standard","hentry","category-unity"],"_links":{"self":[{"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=\/wp\/v2\/posts\/1188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1188"}],"version-history":[{"count":9,"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=\/wp\/v2\/posts\/1188\/revisions"}],"predecessor-version":[{"id":1199,"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=\/wp\/v2\/posts\/1188\/revisions\/1199"}],"wp:attachment":[{"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mapleriver.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}