{"id":95511,"date":"2026-08-26T13:40:26","date_gmt":"2026-08-26T05:40:26","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/95511.html"},"modified":"2026-08-26T13:40:26","modified_gmt":"2026-08-26T05:40:26","slug":"%e3%80%90stl%e3%80%91%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%ef%bc%88c%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/95511.html","title":{"rendered":"\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09"},"content":{"rendered":"<hr \/>\n<p>C&#043;&#043;\u6807\u51c6\u5e93\u539f\u751f\u652f\u6301\u591a\u79cd\u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u8303&#xff0c;\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u8bb2\u89e3\u5728\u4f7f\u7528\u6b63\u5219\u529f\u80fd\u65f6\u53ef\u4f9b\u9009\u62e9\u7684\u5404\u7c7b\u8bed\u6cd5\u4f53\u7cfb\u5dee\u5f02\u3002<\/p>\n<hr \/>\n<h4>\u76ee\u5f55<\/h4>\n<ul>\n<li>1 \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u5219<\/li>\n<li>\n<ul>\n<li>1.1 \u6982\u8ff0<\/li>\n<li>\n<ul>\n<li>1.1.1 \u6982\u8ff0<\/li>\n<li>1.1.2 \u914d\u5957\u4fee\u9970\u6807\u8bc6&#xff08;Flag&#xff09;<\/li>\n<li>1.1.3 \u8865\u5145\u8bf4\u660e<\/li>\n<\/ul>\n<\/li>\n<li>1.2 \u8bed\u6cd5\u5355\u5143&#xff08;Element&#xff09;<\/li>\n<li>\n<ul>\n<li>1.2.1 \u6240\u6709\u6b63\u5219\u8bed\u6cd5\u901a\u7528\u57fa\u7840\u5355\u5143<\/li>\n<li>1.2.2 ECMAScript&#xff08;C&#043;&#043;\u9ed8\u8ba4\u6b63\u5219\u8bed\u6cd5&#xff09;\u989d\u5916\u652f\u6301\u7684\u5355\u5143<\/li>\n<li>1.2.3 awk \u8bed\u6cd5\u4e13\u5c5e\u6269\u5c55\u5355\u5143<\/li>\n<li>1.2.4 \u8865\u5145\u8981\u70b9<\/li>\n<\/ul>\n<\/li>\n<li>1.3 \u91cd\u590d&#xff08;Repetition&#xff09;<\/li>\n<li>\n<ul>\n<li>1.3.1 \u6982\u8ff0<\/li>\n<li>1.3.2 \u5173\u952e\u77e5\u8bc6\u70b9&#xff08;C&#043;&#043; std::regex \u91cd\u70b9&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>1.4 \u8fde\u63a5&#xff08;Concatenation&#xff09;<\/li>\n<li>\n<ul>\n<li>1.4.1 \u6982\u8ff0<\/li>\n<li>1.4.2 \u8865\u5145\u8981\u70b9<\/li>\n<\/ul>\n<\/li>\n<li>1.5 \u5206\u652f\u9009\u62e9&#xff08;Alternation&#xff09;<\/li>\n<li>\n<ul>\n<li>1.5.1 \u6982\u8ff0<\/li>\n<li>1.5.2 \u6838\u5fc3\u8981\u70b9<\/li>\n<\/ul>\n<\/li>\n<li>1.6 \u5b50\u8868\u8fbe\u5f0f&#xff08;subexpression&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>2 \u8bed\u6cd5\u603b\u89c8<\/li>\n<li>3 \u8bed\u4e49\u8be6\u7ec6\u4fe1\u606f<\/li>\n<li>\n<ul>\n<li>3.1 \u4f4d\u7f6e\u951a\u70b9<\/li>\n<li>3.2 \u53cd\u5411\u5f15\u7528<\/li>\n<li>3.3 \u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f<\/li>\n<li>3.4 \u6355\u83b7\u7ec4<\/li>\n<li>3.5 \u5b57\u7b26\u7c7b<\/li>\n<li>3.6 \u5b57\u7b26\u533a\u95f4<\/li>\n<li>3.7 \u6392\u5e8f\u5143\u7d20<\/li>\n<li>3.8 \u6392\u5e8f\u7b26\u53f7<\/li>\n<li>3.9 \u63a7\u5236\u8f6c\u4e49\u5e8f\u5217<\/li>\n<li>3.10 DSW \u5b57\u7b26\u8f6c\u4e49<\/li>\n<li>3.11 \u7b49\u4ef7\u7c7b<\/li>\n<li>3.12 \u6587\u4ef6\u683c\u5f0f\u8f6c\u4e49\u5b57\u7b26<\/li>\n<li>3.13 \u5341\u516d\u8fdb\u5236\u8f6c\u4e49\u5e8f\u5217<\/li>\n<li>3.14 \u5b57\u9762\u8f6c\u4e49&#xff08;\u6052\u7b49\u8f6c\u4e49 \/ Identity-escape&#xff09;<\/li>\n<li>3.15 \u666e\u901a\u5b57\u7b26&#xff08;Individual character&#xff09;<\/li>\n<li>3.16 \u8d1f\u5411\u65ad\u8a00<\/li>\n<li>3.17 \u8d1f\u5411\u5355\u8bcd\u8fb9\u754c\u65ad\u8a00&#xff08;Negative word boundary assert&#xff09;<\/li>\n<li>3.18 \u975e\u6355\u83b7\u7ec4&#xff08;Non-capture group&#xff09;<\/li>\n<li>3.19 \u975e\u8d2a\u5a6a\u91cd\u590d<\/li>\n<li>3.20 \u516b\u8fdb\u5236\u8f6c\u4e49\u5e8f\u5217&#xff08;Octal escape sequence&#xff09;<\/li>\n<li>3.21 \u666e\u901a\u5b57\u7b26&#xff08;Ordinary character&#xff09;<\/li>\n<li>3.22 \u6b63\u5411\u65ad\u8a00&#xff08;Positive assert&#xff09;<\/li>\n<li>3.23 Unicode \u8f6c\u4e49\u5e8f\u5217&#xff08;Unicode escape sequence&#xff09;<\/li>\n<li>3.24 \u901a\u914d\u7b26&#xff08;Wildcard character&#xff0c;. \u70b9\u53f7&#xff09;<\/li>\n<li>3.25 \u5355\u8bcd\u8fb9\u754c&#xff08;Word boundary&#xff0c;\\\\b&#xff09;<\/li>\n<li>3.26 \u5355\u8bcd\u8fb9\u754c\u65ad\u8a00&#xff08;Word boundary assert&#xff0c;\\\\b&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>4 \u5339\u914d\u4e0e\u641c\u7d22<\/li>\n<li>5 \u683c\u5f0f\u6807\u5fd7 \/ \u66ff\u6362\u6587\u672c\u5360\u4f4d\u7b26&#xff08;ECMAScript \u66ff\u6362\u89c4\u5219&#xff09;<\/li>\n<\/ul>\n<h2>1 \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u5219<\/h2>\n<h3>1.1 \u6982\u8ff0<\/h3>\n<h4>1.1.1 \u6982\u8ff0<\/h4>\n<p>\u5f00\u53d1\u8005\u901a\u8fc7\u679a\u4e3e\u7c7b\u578b std::regex_constants::syntax_option_type \u9009\u5b9a\u6b63\u5219\u6240\u91c7\u7528\u7684\u8bed\u6cd5\u98ce\u683c&#xff0c;\u6807\u51c6\u5e93\u5728 std::regex_constants \u4e2d\u63d0\u4f9b\u4e86 6 \u5957\u4e3b\u6d41\u8bed\u6cd5\u89c4\u8303&#xff1a;<\/p>\n<li>ECMAScript&#xff1a;\u9ed8\u8ba4\u8bed\u6cd5&#xff0c;\u8bed\u6cd5\u89c4\u5219\u4e0e JavaScript\u3001.NET \u7684\u6b63\u5219\u9ad8\u5ea6\u4e00\u81f4&#xff1b;<\/li>\n<li>basic&#xff1a;POSIX \u57fa\u7840\u6b63\u5219&#xff08;BRE&#xff09;&#xff1b;<\/li>\n<li>extended&#xff1a;POSIX \u6269\u5c55\u6b63\u5219&#xff08;ERE&#xff09;&#xff1b;<\/li>\n<li>awk&#xff1a;\u5728\u6269\u5c55\u6b63\u5219\u57fa\u7840\u4e0a&#xff0c;\u65b0\u589e\u4e86\u66f4\u591a\u4e0d\u53ef\u89c1\u5b57\u7b26\u7684\u8f6c\u4e49\u5199\u6cd5&#xff1b;<\/li>\n<li>grep&#xff1a;\u57fa\u4e8e\u57fa\u7840\u6b63\u5219&#xff0c;\u989d\u5916\u652f\u6301\u6362\u884c\u7b26 \\\\n \u5206\u9694\u591a\u4e2a\u591a\u9009\u5339\u914d\u5206\u652f&#xff1b;<\/li>\n<li>egrep&#xff1a;\u57fa\u4e8e\u6269\u5c55\u6b63\u5219&#xff0c;\u540c\u6837\u5141\u8bb8\u6362\u884c\u7b26\u5212\u5206\u5339\u914d\u5206\u652f&#xff1b;<\/li>\n<p>\u7a0b\u5e8f\u9ed8\u8ba4\u91c7\u7528 ECMAScript \u8bed\u6cd5&#xff1b;\u4e00\u6b21\u914d\u7f6e\u53ea\u80fd\u9009\u5b9a\u5176\u4e2d\u4e00\u79cd\u8bed\u6cd5&#xff0c;\u4e0d\u53ef\u6df7\u7528\u591a\u79cd\u8bed\u6cd5\u6807\u51c6\u3002<\/p>\n<h4>1.1.2 \u914d\u5957\u4fee\u9970\u6807\u8bc6&#xff08;Flag&#xff09;<\/h4>\n<p>\u53ef\u642d\u914d\u8bed\u6cd5&#xff0c;\u8ffd\u52a0\u4efb\u610f\u6570\u91cf\u7684\u6807\u8bc6\u6765\u4fee\u6539\u6b63\u5219\u5f15\u64ce\u5de5\u4f5c\u65b9\u5f0f&#xff1a;<\/p>\n<ul>\n<li>icase&#xff1a;\u5339\u914d\u8fc7\u7a0b\u5ffd\u7565\u5b57\u6bcd\u5927\u5c0f\u5199&#xff1b;<\/li>\n<li>nosubs&#xff1a;\u5ffd\u7565\u62ec\u53f7\u5185\u7684\u6355\u83b7\u5206\u7ec4&#xff0c;\u4e0d\u5b58\u50a8\u5206\u7ec4\u5339\u914d\u5230\u7684\u5185\u5bb9&#xff1b;<\/li>\n<li>optimize&#xff1a;\u4f18\u5316\u5339\u914d\u8fd0\u884c\u901f\u5ea6&#xff0c;\u4f46\u6b63\u5219\u7f16\u8bd1\u6784\u9020\u9636\u6bb5\u8017\u65f6\u4f1a\u4e0a\u5347&#xff1b;<\/li>\n<li>collate&#xff1a;\u4f9d\u7167\u7cfb\u7edf\u672c\u5730\u533a\u57df\u7684\u5b57\u7b26\u6392\u5e8f\u89c4\u5219\u89e3\u6790\u5b57\u7b26\u533a\u95f4&#xff08;\u4f8b\u5982 [a-z]&#xff09;&#xff1b;<\/li>\n<\/ul>\n<p>\u8bed\u6cd5\u6807\u8bc6\u4e0e\u884c\u4e3a\u6807\u8bc6\u53ef\u4ee5\u81ea\u7531\u7ec4\u5408&#xff1b;\u82e5\u53ea\u586b\u5199\u884c\u4e3a\u6807\u8bc6\u3001\u672a\u6307\u5b9a\u8bed\u6cd5&#xff0c;\u4f9d\u65e7\u9ed8\u8ba4\u4f7f\u7528 ECMAScript \u8bed\u6cd5&#xff1b;<\/p>\n<h4>1.1.3 \u8865\u5145\u8bf4\u660e<\/h4>\n<li>\u65e5\u5e38\u5f00\u53d1\u7edd\u5927\u591a\u6570\u573a\u666f\u76f4\u63a5\u4f7f\u7528\u9ed8\u8ba4 ECMAScript \u8bed\u6cd5\u5373\u53ef&#xff0c;\u4e0a\u624b\u6210\u672c\u6700\u4f4e&#xff1b;<\/li>\n<li>POSIX \u7cfb\u5217\u8bed\u6cd5&#xff08;basic \/ extended \/ grep \/ egrep&#xff09;\u591a\u7528\u4e8e\u5bf9\u63a5 Linux \u547d\u4ee4\u884c\u6b63\u5219\u4f7f\u7528\u4e60\u60ef&#xff1b;<\/li>\n<li>\u591a\u4e2a flag \u4e4b\u95f4\u4f7f\u7528\u6309\u4f4d\u6216\u8fd0\u7b97\u7b26 | \u62fc\u63a5\u7ec4\u5408&#xff1b;<\/li>\n<h3>1.2 \u8bed\u6cd5\u5355\u5143&#xff08;Element&#xff09;<\/h3>\n<p>\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u7ec4\u6210\u5355\u5143\u5206\u4e3a\u4ee5\u4e0b\u901a\u7528\u7c7b\u578b&#xff0c;\u540c\u65f6 ECMAScript\u3001awk \u8bed\u6cd5\u5404\u81ea\u6269\u5c55\u4e86\u4e13\u5c5e\u8bed\u6cd5\u5355\u5143\u3002<\/p>\n<h4>1.2.1 \u6240\u6709\u6b63\u5219\u8bed\u6cd5\u901a\u7528\u57fa\u7840\u5355\u5143<\/h4>\n<li>\n<p>\u666e\u901a\u5b57\u7b26<\/p>\n<ul>\n<li>\u5339\u914d\u76ee\u6807\u6587\u672c\u4e2d\u5b8c\u5168\u76f8\u540c\u7684\u5355\u4e2a\u5b57\u7b26\u3002\u4f8b&#xff1a;a \u53ea\u80fd\u5339\u914d\u5b57\u7b26 a&#xff0c;\u65e0\u6cd5\u5339\u914d\u5927\u5199 B\u3001\u5c0f\u5199 b \u3001c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u901a\u914d\u7b26 .<\/p>\n<ul>\n<li>\u5339\u914d\u9664\u6362\u884c\u7b26\u4ee5\u5916\u7684\u4efb\u610f\u5355\u4e2a\u5b57\u7b26&#xff1b;\u4f8b&#xff1a;. \u53ef\u5339\u914d a\u3001B\u3001b\u3001c \u4efb\u610f\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f [expr]\u3001[^expr]<\/p>\n<ul>\n<li>[expr]&#xff1a;\u5339\u914d\u76ee\u6807\u5b57\u7b26 \/ \u6392\u5e8f\u5143\u7d20\u51fa\u73b0\u5728 expr \u5b9a\u4e49\u96c6\u5408\u5185\u7684\u5185\u5bb9&#xff1b;<\/li>\n<li>[\\\\^expr]&#xff1a;\u5339\u914d\u76ee\u6807\u5b57\u7b26 \/ \u6392\u5e8f\u5143\u7d20\u4e0d\u5728 expr \u96c6\u5408\u4e2d\u7684\u5185\u5bb9&#xff1b;<\/li>\n<li>\u65b9\u62ec\u53f7\u5185\u90e8 expr \u53ef\u7ec4\u5408\u4e66\u5199\u4ee5\u4e0b\u89c4\u5219&#xff1a;\n<ul>\n<li>\u5355\u4e2a\u5b57\u9762\u5b57\u7b26&#xff1a;\u5c06\u8be5\u5b57\u7b26\u52a0\u5165\u5339\u914d\u96c6\u5408&#xff1b;<\/li>\n<li>\u5b57\u7b26\u533a\u95f4 ch1-ch2&#xff1a;\u5339\u914d\u95ed\u533a\u95f4 [ch1&#xff0c;ch2] \u5185\u6240\u6709\u5b57\u7b26&#xff0c;\u5982 [b-z] \u5339\u914d b\u3001c&#xff0c;\u4e0d\u5339\u914d a\u3001B&#xff1b;<\/li>\n<li>\u6807\u51c6\u5b57\u7b26\u7c7b [:\u540d\u79f0:]&#xff1a;\u4f8b\u5982 [:lower:] \u5339\u914d\u6240\u6709\u5c0f\u5199\u5b57\u6bcd a\/b\/c&#xff0c;\u4e0d\u4f1a\u5339\u914d\u5927\u5199 B&#xff1b;<\/li>\n<li>\u7b49\u4ef7\u7c7b [&#061;elt&#061;]&#xff1a;\u5339\u914d\u6240\u6709\u4e0e elt \u7b49\u4ef7\u7684\u6392\u5e8f\u5b57\u7b26&#xff1b;<\/li>\n<li>\u6392\u5e8f\u7b26\u53f7 [.elt.]&#xff1a;\u5c06 elt \u8fd9\u4e2a\u6392\u5e8f\u5355\u5143\u52a0\u5165\u5339\u914d\u96c6\u5408&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u951a\u70b9\u7b26\u53f7<\/p>\n<ul>\n<li>^ \u5339\u914d\u6574\u4e2a\u5b57\u7b26\u4e32\u7684\u8d77\u59cb\u4f4d\u7f6e&#xff1b;<\/li>\n<li>$ \u5339\u914d\u6574\u4e2a\u5b57\u7b26\u4e32\u7684\u672b\u5c3e\u4f4d\u7f6e&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6355\u83b7\u5206\u7ec4<\/p>\n<ul>\n<li>ECMAScript\u3001extended\u3001egrep\u3001awk&#xff1a;\u5199\u6cd5&#xff08;\u5b50\u8868\u8fbe\u5f0f&#xff09;<\/li>\n<li>basic\u3001grep \u65e7\u5f0f POSIX \u8bed\u6cd5&#xff1a;\u5199\u6cd5 \\\\(\u5b50\u8868\u8fbe\u5f0f\\\\)\n<ul>\n<li>\u5339\u914d\u62ec\u53f7\u5185\u89c4\u5219\u5bf9\u5e94\u7684\u5b57\u7b26\u7247\u6bb5&#xff0c;\u540c\u65f6\u4fdd\u5b58\u5339\u914d\u7ed3\u679c\u81f3\u5206\u7ec4\u7f16\u53f7\u3002\u793a\u4f8b&#xff1a;(a) \u5339\u914d\u5b57\u7b26 a&#xff0c;\u5e76\u5c06\u5185\u5bb9\u5b58\u5165 1 \u53f7\u6355\u83b7\u7ec4\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u672c\u4e49\u8f6c\u4e49 \\\\k<\/p>\n<ul>\n<li>\u5339\u914d\u5b57\u7b26 k \u672c\u8eab&#xff0c;\u7528\u6765\u5bf9\u70b9\u53f7\u3001\u62ec\u53f7\u7b49\u5143\u5b57\u7b26\u8fdb\u884c\u8f6c\u4e49&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u53cd\u5411\u5f15\u7528&#xff08;ECMAScript\u3001basic\u3001grep \u652f\u6301&#xff09;<\/p>\n<ul>\n<li>\u683c\u5f0f \\\\\u6570\u5b57&#xff0c;\u590d\u7528\u7b2c N \u4e2a\u6355\u83b7\u7ec4\u5df2\u7ecf\u5339\u914d\u5230\u7684\u6587\u672c&#xff1b;<\/li>\n<li>\u793a\u4f8b&#xff1a;(a)\\\\1&#xff0c;\u7b2c\u4e00\u4e2a\u5206\u7ec4\u6355\u83b7 a&#xff0c;\\\\1 \u518d\u6b21\u5339\u914d a&#xff0c;\u6574\u4f53\u5339\u914d\u5b57\u7b26\u4e32 aa\u3002<\/li>\n<\/ul>\n<\/li>\n<h4>1.2.2 ECMAScript&#xff08;C&#043;&#043;\u9ed8\u8ba4\u6b63\u5219\u8bed\u6cd5&#xff09;\u989d\u5916\u652f\u6301\u7684\u5355\u5143<\/h4>\n<li>\u975e\u6355\u83b7\u5206\u7ec4&#xff08;?:\u5b50\u8868\u8fbe\u5f0f&#xff09;&#xff1a;\u5b8c\u6210\u5339\u914d&#xff0c;\u4f46\u4e0d\u4f1a\u5b58\u50a8\u5206\u7ec4\u6570\u636e&#xff1b;(?:a)\\\\1 \u5199\u6cd5\u975e\u6cd5&#xff0c;\u65e0\u53ef\u7528\u6355\u83b7\u7ec4\u3002<\/li>\n<li>\u683c\u5f0f\u8f6c\u4e49\u5b57\u7b26&#xff1a;\\\\f \u6362\u9875\u7b26\u3001\\\\n \u6362\u884c\u3001\\\\r \u56de\u8f66\u3001\\\\t \u6c34\u5e73\u5236\u8868\u7b26\u3001\\\\v \u5782\u76f4\u5236\u8868\u7b26\u3002<\/li>\n<li>\u96f6\u5bbd\u65ad\u8a00&#xff08;\u73af\u89c6&#xff09;\n<ul>\n<li>\u6b63\u5411\u5148\u884c\u65ad\u8a00 (?&#061;\u5b50\u8868\u8fbe\u5f0f)&#xff1a;\u6821\u9a8c\u540e\u65b9\u6587\u672c\u7b26\u5408\u89c4\u5219&#xff0c;\u4f46\u4e0d\u4f1a\u6d88\u8017\u5339\u914d\u6307\u9488&#xff1b;(?&#061;a)a \u53ef\u4ee5\u5339\u914d\u5b57\u7b26\u4e32 a&#xff1b;<\/li>\n<li>\u8d1f\u5411\u5148\u884c\u65ad\u8a00 (?!\u5b50\u8868\u8fbe\u5f0f)&#xff1a;\u6821\u9a8c\u540e\u65b9\u6587\u672c\u4e0d\u7b26\u5408\u89c4\u5219&#xff1b;(?!a)a \u65e0\u6cd5\u5339\u914d a\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u8fdb\u5236\u8f6c\u4e49\n<ul>\n<li>\\\\xhh&#xff1a;\u4e24\u4f4d\u5341\u516d\u8fdb\u5236\u8868\u793a\u4e00\u4e2a\u5b57\u7b26&#xff1b;<\/li>\n<li>\\\\uhhhh&#xff1a;\u56db\u4f4d\u5341\u516d\u8fdb\u5236\u8868\u793a\u4e00\u4e2a Unicode \u5b57\u7b26&#xff1b;<\/li>\n<li>\\\\ck \u5339\u914d\u5bf9\u5e94\u63a7\u5236\u5b57\u7b26&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u5355\u8bcd\u8fb9\u754c\n<ul>\n<li>\\\\b&#xff1a;\u5339\u914d\u5355\u8bcd\u8fb9\u754c\u4f4d\u7f6e&#xff1b;<\/li>\n<li>\\\\B&#xff1a;\u5339\u914d\u975e\u5355\u8bcd\u8fb9\u754c&#xff1b;<\/li>\n<li>\u4f8b&#xff1a;a\\\\b. \u5339\u914d a~&#xff0c;\u4e0d\u5339\u914d ab&#xff1b;a\\\\B. \u5339\u914d ab&#xff0c;\u4e0d\u5339\u914d a~&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u7b80\u5199\u5b57\u7b26\u96c6\n<ul>\n<li>\\\\d \\\\D (\u6570\u5b57\/\u975e\u6570\u5b57)\u3001\\\\s \\\\S (\u7a7a\u767d\/\u975e\u7a7a\u767d)\u3001\\\\w \\\\W(\u5355\u8bcd\u5b57\u7b26\/\u975e\u5355\u8bcd\u5b57\u7b26)\u3002<\/li>\n<\/ul>\n<\/li>\n<h4>1.2.3 awk \u8bed\u6cd5\u4e13\u5c5e\u6269\u5c55\u5355\u5143<\/h4>\n<li>\u8865\u5145\u8f6c\u4e49\u7b26&#xff1a;\\\\ \u53cd\u659c\u6760\u3001\\\\a \u544a\u8b66\u97f3\u3001\\\\b \u9000\u683c\u952e&#xff0c;\u5916\u52a0\u901a\u7528\u7684 \\\\f\\\\n\\\\r\\\\t\\\\v\u3002<\/li>\n<li>\u516b\u8fdb\u5236\u8f6c\u4e49 \\\\ooo&#xff1a;1~3\u4f4d\u516b\u8fdb\u5236\u6570\u5b57&#xff0c;\u89e3\u6790\u4e3a\u5bf9\u5e94 ASCII \u5b57\u7b26\u3002<\/li>\n<h4>1.2.4 \u8865\u5145\u8981\u70b9<\/h4>\n<li>C&#043;&#043; regex \u9ed8\u8ba4\u91c7\u7528 ECMAScript \u8bed\u6cd5&#xff0c;\u529f\u80fd\u6700\u5168\u9762&#xff0c;\u65e5\u5e38\u5f00\u53d1\u9996\u9009&#xff1b;<\/li>\n<li>BRE\/grep POSIX \u8bed\u6cd5\u9700\u8981\u5bf9\u62ec\u53f7\u6dfb\u52a0\u53cd\u659c\u6760\u8f6c\u4e49&#xff0c;\u4e66\u5199\u7e41\u7410&#xff1b;<\/li>\n<li>\u96f6\u5bbd\u65ad\u8a00\u53ea\u505a\u4f4d\u7f6e\u6821\u9a8c&#xff0c;\u4e0d\u4f1a\u5360\u7528\u5b57\u7b26&#xff0c;\u662f\u6b63\u5219\u5339\u914d\u91cc\u9ad8\u9891\u5b9e\u7528\u8bed\u6cd5&#xff1b;<\/li>\n<h3>1.3 \u91cd\u590d&#xff08;Repetition&#xff09;<\/h3>\n<p>\u672c\u6bb5\u4ecb\u7ecd\u6b63\u5219\u8868\u8fbe\u5f0f\u91cf\u8bcd&#xff08;\u91cd\u590d\u9650\u5b9a Repetition&#xff09;\u89c4\u5219&#xff1a;<\/p>\n<ul>\n<li>\u9664\u96f6\u5bbd\u65ad\u8a00\u3001\u951a\u70b9\u4e4b\u5916\u7684\u4efb\u610f\u6b63\u5219\u5143\u7d20\u540e\u90fd\u53ef\u4ee5\u9644\u52a0\u91cd\u590d\u6b21\u6570\u9650\u5b9a\u7b26 {min,max}&#xff1b;<\/li>\n<li>\u533a\u5206 POSIX BRE&#xff08;basic\/grep&#xff09;\u4e0e\u5176\u4ed6\u8bed\u6cd5&#xff08;ECMAScript\u3001ERE\u3001awk\u3001egrep&#xff09;\u652f\u6301\u7684\u7b80\u5199\u7b26\u53f7 * &#043; ?&#xff1b;<\/li>\n<li>* \u7b49\u4ef7 {0,\u65e0\u7a77}&#xff0c;&#043; \u7b49\u4ef7 {1,\u65e0\u7a77}&#xff0c;? \u7b49\u4ef7 {0,1}&#xff1b;<\/li>\n<\/ul>\n<p>ECMAScript \u8bed\u6cd5\u652f\u6301\u5728\u91cf\u8bcd\u540e\u8ffd\u52a0 ? \u5b9e\u73b0\u975e\u8d2a\u5a6a\u5339\u914d\u3002<\/p>\n<h4>1.3.1 \u6982\u8ff0<\/h4>\n<ul>\n<li>\u9664\u6b63\u5411\u65ad\u8a00\u3001\u53cd\u5411\u65ad\u8a00\u3001\u951a\u70b9\u4e4b\u5916\u7684\u4efb\u610f\u5143\u7d20&#xff0c;\u540e\u65b9\u90fd\u53ef\u4ee5\u8ddf\u968f\u91cd\u590d\u6b21\u6570\u9650\u5b9a&#xff1b;<\/li>\n<li>\u6700\u901a\u7528\u7684\u91cd\u590d\u5199\u6cd5\u4e3a {min,max}&#xff1b;\u5728 basic\u3001grep&#xff08;BRE \u57fa\u7840\u6b63\u5219&#xff09;\u8bed\u6cd5\u4e2d\u9700\u8981\u5199\u6210 \\\\{min,max\\\\}\u3002<\/li>\n<li>\u88ab\u8be5\u91cf\u8bcd\u4fee\u9970\u7684\u5143\u7d20&#xff0c;\u5339\u914d\u6700\u5c11 min \u6b21\u3001\u6700\u591a max \u6b21\u8fde\u7eed\u51fa\u73b0&#xff1b;<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff1a;a{2,3} \u5339\u914d aa\u3001aaa&#xff1b;\u4e0d\u5339\u914d a\u3001aaaa&#xff1b;<\/p>\n<p>\u91cd\u590d\u9650\u5b9a\u8fd8\u6709\u4ee5\u4e0b\u5f62\u5f0f&#xff1a;<\/p>\n<li>{min}&#xff08;basic\/grep \u4e2d\u4e3a \\\\{min\\\\}&#xff09;&#xff1a;\u7b49\u4ef7 {min,min}&#xff0c;\u7cbe\u786e\u5339\u914d min \u6b21<\/li>\n<li>{min,}&#xff08;basic\/grep \u4e2d\u4e3a \\\\{min,\\\\}&#xff09;&#xff1a;\u81f3\u5c11\u5339\u914d min \u6b21&#xff0c;\u65e0\u4e0a\u9650<\/li>\n<li>*&#xff1a;\u7b49\u4ef7 {0,\u65e0\u4e0a\u9650}<\/li>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>a{2}&#xff1a;\u53ea\u5339\u914d aa&#xff0c;\u4e0d\u5339\u914d a\u3001aaa&#xff1b;<\/li>\n<li>a{2,}&#xff1a;\u5339\u914d aa\u3001aaa\u2026&#xff0c;\u4e0d\u5339\u914d\u5355\u4e2a a&#xff1b;<\/li>\n<li>a*&#xff1a;\u5339\u914d\u7a7a\u5b57\u7b26\u4e32\u3001a\u3001aa\u2026&#xff1b;<\/li>\n<\/ul>\n<p>\u9664 basic\u3001grep \u4ee5\u5916\u7684\u6240\u6709\u6b63\u5219\u8bed\u6cd5&#xff0c;\u989d\u5916\u652f\u6301\u4e24\u79cd\u7b80\u5199\u91cf\u8bcd&#xff1a;<\/p>\n<ul>\n<li>? \u7b49\u6548\u4e8e {0,1}&#xff1b;<\/li>\n<li>&#043; \u7b49\u6548\u4e8e {1,\u65e0\u4e0a\u9650}&#xff1b;<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>a?&#xff1a;\u5339\u914d\u7a7a\u5b57\u7b26\u4e32\u3001a\u3001\u4e0d\u5339\u914d aa&#xff1b;<\/li>\n<li>a&#043;&#xff1a;\u5339\u914d a\u3001aa\u2026&#xff0c;\u4e0d\u80fd\u5339\u914d\u7a7a\u5b57\u7b26\u4e32&#xff1b;<\/li>\n<\/ul>\n<p>\u5728 ECMAScript \u6a21\u5f0f\u4e0b&#xff0c;\u6240\u6709\u91cf\u8bcd\u540e\u9762\u5747\u53ef\u8ffd\u52a0 ?&#xff0c;\u4ee3\u8868\u975e\u8d2a\u5a6a&#xff08;\u60f0\u6027&#xff09;\u5339\u914d\u3002<\/p>\n<h4>1.3.2 \u5173\u952e\u77e5\u8bc6\u70b9&#xff08;C&#043;&#043; std::regex \u91cd\u70b9&#xff09;<\/h4>\n<li>\u8bed\u6cd5\u5dee\u5f02\u5927\u5751&#xff08;C&#043;&#043; \u5fc5\u770b&#xff09;\n<ul>\n<li>regex_constants::basic \/ grep&#xff08;POSIX BRE&#xff09;&#xff1a;&#043; ? \u4e0d\u539f\u751f\u652f\u6301&#xff0c;\u5927\u62ec\u53f7\u5fc5\u987b\u8f6c\u4e49 \\\\{ \\\\}&#xff1b;<\/li>\n<li>\u9ed8\u8ba4\u6a21\u5f0f ECMAScript\u3001extended\u3001awk\u3001egrep&#xff1a;\u76f4\u63a5\u4f7f\u7528 &#043; ? {m,n}&#xff0c;\u65e0\u9700\u8f6c\u4e49&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u8d2a\u5a6a vs \u975e\u8d2a\u5a6a\n<ul>\n<li>\u4ec5 ECMAScript \u8bed\u6cd5\u652f\u6301 .*?\u3001a{2,3}? \u8fd9\u7c7b\u60f0\u6027\u5199\u6cd5&#xff1b;POSIX ERE\/BRE \u4e0d\u652f\u6301\u975e\u8d2a\u5a6a\u91cf\u8bcd\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u53ef\u6dfb\u52a0\u91cf\u8bcd\u7684\u5bf9\u8c61\u9650\u5236\n<ul>\n<li>\u2705\ufe0f&#xff1a;\u666e\u901a\u5b57\u7b26\u3001.\u3001\u62ec\u53f7\u5206\u7ec4\u3001\u5b57\u7b26\u96c6[]&#xff1b;<\/li>\n<li>\u274c\ufe0f&#xff1a;^ $ \u951a\u70b9\u3001\\\\b\u3001\u524d\u540e\u5411\u65ad\u8a00&#xff08;\u4e0d\u80fd\u5bf9\u96f6\u5bbd\u4fee\u9970\u91cd\u590d&#xff09;<\/li>\n<\/ul>\n<\/li>\n<p>\u91cf\u8bcd\u5bf9\u7167\u8868&#xff1a;<\/p>\n<table>\n<tr>\u8868\u8fbe\u5f0f\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>X{n}<\/td>\n<td>X \u6070\u597d\u51fa\u73b0 n \u6b21<\/td>\n<\/tr>\n<tr>\n<td>X{n,}<\/td>\n<td>X \u81f3\u5c11 n \u6b21<\/td>\n<\/tr>\n<tr>\n<td>X{n,m}<\/td>\n<td>X n~m \u6b21<\/td>\n<\/tr>\n<tr>\n<td>X*<\/td>\n<td>X 0\u6b21\u6216\u591a\u6b21<\/td>\n<\/tr>\n<tr>\n<td>X&#043;<\/td>\n<td>X 1\u6b21\u6216\u591a\u6b21<\/td>\n<\/tr>\n<tr>\n<td>X?<\/td>\n<td>X 0\u6b21\u62161\u6b21<\/td>\n<\/tr>\n<tr>\n<td>X&#043;?<\/td>\n<td>ECMAScript&#xff1a;\u6700\u5c11\u5339\u914d&#xff08;\u975e\u8d2a\u5a6a&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>1.4 \u8fde\u63a5&#xff08;Concatenation&#xff09;<\/h3>\n<p>\u672c\u8282\u8bb2\u89e3\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u8fde\u63a5\u89c4\u5219&#xff1a; \u591a\u4e2a\u6b63\u5219\u5143\u7d20&#xff08;\u53ef\u643a\u5e26\u91cd\u590d\u91cf\u8bcd&#xff09;\u76f4\u63a5\u76f8\u90bb\u4e66\u5199&#xff0c;\u6784\u6210\u62fc\u63a5\u8868\u8fbe\u5f0f\u3002\u5339\u914d\u903b\u8f91\u8981\u6c42\u76ee\u6807\u6587\u672c\u6309\u987a\u5e8f\u4f9d\u6b21\u5339\u914d\u6bcf\u4e00\u4e2a\u5143\u7d20\u3002<\/p>\n<ul>\n<li>\u793a\u4f8b&#xff1a;a{2,3}b \u5339\u914d 2~3 \u4e2a a \u540e\u9762\u7d27\u8ddf 1 \u4e2a b&#xff1b;<\/li>\n<\/ul>\n<h4>1.4.1 \u6982\u8ff0<\/h4>\n<p>\u6b63\u5219\u8868\u8fbe\u5f0f\u5143\u7d20&#xff08;\u65e0\u8bba\u662f\u5426\u5e26\u6709\u91cd\u590d\u91cf\u8bcd&#xff09;\u53ef\u4ee5\u76f8\u4e92\u62fc\u63a5&#xff0c;\u7ec4\u6210\u66f4\u957f\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u62fc\u63a5\u540e\u7684\u8868\u8fbe\u5f0f&#xff0c;\u5339\u914d\u7684\u76ee\u6807\u5b57\u7b26\u4e32\u5fc5\u987b\u4f9d\u6b21\u62fc\u63a5\u5404\u4e2a\u72ec\u7acb\u5143\u7d20\u6240\u5339\u914d\u7684\u5185\u5bb9\u3002<\/p>\n<ul>\n<li>\u4f8b\u5982&#xff1a;a{2,3}b \u80fd\u591f\u5339\u914d \u201caab\u201d\u3001\u201caaab\u201d&#xff0c;\u4f46\u65e0\u6cd5\u5339\u914d \u201cab\u201d\u3001\u201caaaab\u201d\u3002<\/li>\n<\/ul>\n<h4>1.4.2 \u8865\u5145\u8981\u70b9<\/h4>\n<li>\u8bed\u6cd5\u7279\u70b9\n<ul>\n<li>\u6b63\u5219\u4e2d\u4e0d\u9700\u8981\u4efb\u4f55\u8fd0\u7b97\u7b26&#xff0c;\u5143\u7d20\u7d27\u90bb\u5373\u4ee3\u8868\u987a\u5e8f\u62fc\u63a5&#xff1b;<\/li>\n<li>ab &#061; a \u540e\u9762\u7d27\u8ddf b&#xff0c;\u8fd9\u662f\u6b63\u5219\u6700\u57fa\u7840\u7684\u9690\u5f0f\u8fd0\u7b97\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u4f18\u5148\u7ea7\u5173\u7cfb&#xff08;\u7531\u9ad8\u5230\u4f4e&#xff09;\n<ul>\n<li>\u91cd\u590d\u91cf\u8bcd \u2192 \u62fc\u63a5&#xff08;\u5e8f\u5217&#xff09;\u2192 \u9009\u62e9\u7b26 |\n<ul>\n<li>\u793a\u4f8b&#xff1a;ab|cd \u7b49\u4ef7 (ab)|(cd)&#xff0c;\u4e0d\u662f a(b|c)d\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u62d3\u5c55\u793a\u4f8b\n<ul>\n<li>a&#043;b?[0-9]&#xff1a;\u4e00\u4e2a\u6216\u591a\u4e2a a&#xff0c;\u540e\u9762\u53ef\u9009 1 \u4e2a b&#xff0c;\u6700\u540e\u8ddf\u4e0a\u4e00\u4f4d\u6570\u5b57\u3002<\/li>\n<\/ul>\n<\/li>\n<h3>1.5 \u5206\u652f\u9009\u62e9&#xff08;Alternation&#xff09;<\/h3>\n<p>\u672c\u6bb5\u8bb2\u89e3\u6b63\u5219\u7684\u5206\u652f\u9009\u62e9\u7b26 | &#xff1a;<\/p>\n<li>\u9664 basic\u3001grep \u6a21\u5f0f\u4ee5\u5916&#xff0c;\u4f7f\u7528\u7ad6\u7ebf | \u5206\u9694\u591a\u4e2a\u62fc\u63a5\u8868\u8fbe\u5f0f&#xff0c;\u547d\u4e2d\u4efb\u610f\u4e00\u6761\u5206\u652f\u5373\u53ef\u5339\u914d\u6210\u529f\u3002<\/li>\n<li>\u5206\u652f\u5b58\u5728\u5339\u914d\u4f18\u5148\u7ea7\u5dee\u5f02&#xff1a;ECMAScript \u91c7\u7528\u6700\u5148\u547d\u4e2d\u4f18\u5148&#xff1b;\u5176\u4f59\u8bed\u6cd5\u9009\u62e9\u6700\u957f\u5b57\u7b26\u4e32\u4f18\u5148\u3002<\/li>\n<li>grep\u3001egrep \u8fd8\u652f\u6301\u6362\u884c\u7b26 \\\\n \u5145\u5f53\u5206\u652f\u5206\u9694\u7b26\u3002<\/li>\n<h4>1.5.1 \u6982\u8ff0<\/h4>\n<p>\u9664 basic \u4e0e grep \u8bed\u6cd5\u4e4b\u5916&#xff0c;\u6240\u6709\u6b63\u5219\u8bed\u6cd5\u90fd\u5141\u8bb8&#xff1a;\u4e00\u6bb5\u62fc\u63a5\u5f0f\u6b63\u5219\u540e\u9762\u6dfb\u52a0\u7ad6\u7ebf | &#xff0c;\u518d\u63a5\u53e6\u4e00\u6bb5\u62fc\u63a5\u6b63\u5219\u3002 \u53ef\u4ee5\u901a\u8fc7\u8be5\u65b9\u5f0f\u62fc\u63a5\u4efb\u610f\u591a\u6761\u5206\u652f\u8868\u8fbe\u5f0f\u3002\u6700\u7ec8\u7684\u6b63\u5219\u53ea\u8981\u76ee\u6807\u5b57\u7b26\u4e32\u80fd\u591f\u5339\u914d\u5176\u4e2d\u4efb\u610f\u4e00\u6761\u5206\u652f&#xff0c;\u6574\u4f53\u5c31\u5339\u914d\u6210\u529f\u3002<\/p>\n<p>\u5f53\u6709\u591a\u6761\u5206\u652f\u90fd\u53ef\u4ee5\u9002\u914d\u76ee\u6807\u6587\u672c\u65f6&#xff1a;<\/p>\n<ul>\n<li>ECMAScript&#xff1a;\u8fd4\u56de\u6700\u5148\u6210\u529f\u5339\u914d\u7684\u5206\u652f\u7ed3\u679c&#xff1b;<\/li>\n<li>\u5176\u4f59\u6b63\u5219\u8bed\u6cd5&#xff1a;\u6311\u9009\u80fd\u591f\u5339\u914d\u51fa\u6700\u957f\u5b50\u4e32\u7684\u5206\u652f&#xff1b;<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff1a;ab|cd \u53ef\u4ee5\u5339\u914d ab\u3001cd&#xff1b;\u65e0\u6cd5\u5339\u914d abd\u3001acd&#xff1b; \u5728 grep \u548c egrep \u6a21\u5f0f\u4e2d&#xff0c;\u6362\u884c\u7b26 \\\\n \u540c\u6837\u53ef\u4ee5\u7528\u6765\u5206\u9694\u591a\u4e2a\u5206\u652f\u9009\u9879&#xff1b;<\/p>\n<h4>1.5.2 \u6838\u5fc3\u8981\u70b9<\/h4>\n<li>BRE&#xff08;basic \/ grep&#xff09;\u7279\u6b8a\u9650\u5236\n<ul>\n<li>POSIX-\u57fa\u7840\u6b63\u5219\u4e0d\u76f4\u63a5\u652f\u6301\u88f8 | &#xff0c;\u9700\u8981\u8f6c\u4e49 \\\\| \u624d\u80fd\u542f\u7528\u5206\u652f\u529f\u80fd&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>| \u4f18\u5148\u7ea7\u6700\u4f4e\n<ul>\n<li>\u8fd0\u7b97\u4f18\u5148\u7ea7&#xff1a;\u91cf\u8bcd &gt; \u62fc\u63a5 &gt; \u6216\u5206\u652f\n<ul>\n<li>ab|cd &#061; (ab)|(cd)&#xff0c;\u800c\u975e a(b|c)d<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e24\u79cd\u5206\u652f\u7b56\u7565\u533a\u522b\n<ul>\n<li>ECMAScript&#xff08;C&#043;&#043; regex \u9ed8\u8ba4\u6a21\u5f0f&#xff09;&#xff1a;\u4ece\u5de6\u5f80\u53f3\u626b\u63cf&#xff0c;\u6293\u5230\u7b2c\u4e00\u4e2a\u5339\u914d\u9879\u5c31\u76f4\u63a5\u505c\u6b62&#xff1b;<\/li>\n<li>ERE \/ awk \/ egrep&#xff1a;\u5168\u90e8\u5206\u652f\u5bf9\u6bd4&#xff0c;\u9009\u53d6\u5339\u914d\u957f\u5ea6\u6700\u5927\u7684\u7ed3\u679c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>grep \u72ec\u6709\u7279\u6027\n<ul>\n<li>\u53ef\u4ee5\u6362\u884c\u5206\u9694\u5206\u652f&#xff0c;\u7b49\u4ef7\u4e8e a\\\\nb \u7b49\u540c\u4e8e a|b\u3002<\/li>\n<\/ul>\n<\/li>\n<h3>1.6 \u5b50\u8868\u8fbe\u5f0f&#xff08;subexpression&#xff09;<\/h3>\n<p>\u8be5\u6bb5\u4ecb\u7ecd\u6b63\u5219\u4e2d\u5b50\u8868\u8fbe\u5f0f&#xff08;subexpression&#xff09;\u7684\u5b9a\u4e49\u533a\u5206&#xff1a;basic\u3001grep \u8bed\u6cd5\u91cc\u5b50\u8868\u8fbe\u5f0f\u4ee3\u8868\u8868\u8fbe\u5f0f\u62fc\u63a5&#xff1b;\u5176\u4f59\u6b63\u5219\u8bed\u6cd5\u4e2d&#xff0c;\u5b50\u8868\u8fbe\u5f0f\u6307\u7531 | \u6784\u6210\u7684\u5206\u652f\u9009\u62e9\u5355\u5143\u3002<\/p>\n<p>\u5728 basic \u548c grep \u6b63\u5219\u8bed\u6cd5\u4e2d&#xff0c;\u4e00\u4e2a\u5b50\u8868\u8fbe\u5f0f\u5c31\u662f\u4e00\u6bb5\u62fc\u63a5\u7ec4\u5408\u7684\u8868\u8fbe\u5f0f\u3002 \u5176\u4f59\u7c7b\u578b\u7684\u6b63\u5219\u8bed\u6cd5\u4e0b&#xff0c;\u5b50\u8868\u8fbe\u5f0f\u4e3a\u5206\u652f\u9009\u62e9&#xff08;\u7531 | \u5206\u9694\u7684\u591a\u9009\u7ed3\u6784&#xff09;\u3002<\/p>\n<p>\u89e3\u6790<\/p>\n<li>basic(BRE)\/grep\n<ul>\n<li>BRE \u57fa\u7840\u6b63\u5219\u4f18\u5148\u7ea7\u7ed3\u6784&#xff1a;\u62fc\u63a5\u4e3a\u57fa\u7840\u5355\u5143&#xff0c;\\\\| \u8f6c\u4e49\u4e4b\u540e\u624d\u4ee3\u8868\u6216\u8fd0\u7b97&#xff0c;\u56e0\u6b64\u539f\u751f\u5b50\u5355\u5143\u662f\u5b57\u7b26\u62fc\u63a5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>ECMAScript\u3001extended\u3001awk\u3001egrep\n<ul>\n<li>\u8bed\u6cd5\u5c06 | \u5206\u652f\u5f53\u4f5c\u4e00\u5c42\u5b8c\u6574\u5b50\u8868\u8fbe\u5f0f&#xff0c;\u62fc\u63a5\u53ea\u662f\u5206\u652f\u5185\u90e8\u7684\u7ec4\u5408\u3002\n<ul>\n<li>\u4e3e\u4e2a\u4f8b\u5b50&#xff1a;ab|cd \u6574\u4f53\u5c31\u662f\u4e00\u6761\u5b50\u8868\u8fbe\u5f0f&#xff0c;\u5185\u90e8\u7531 ab\u3001cd \u4e24\u4e2a\u62fc\u63a5\u5355\u5143\u7ec4\u6210&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<h2>2 \u8bed\u6cd5\u603b\u89c8<\/h2>\n<p>\u8fd9\u4efd\u5bf9\u7167\u8868\u7f57\u5217 C&#043;&#043; \u6807\u51c6\u5e93\u516d\u79cd\u6b63\u5219\u8bed\u6cd5&#xff08;basic\u3001extended\u3001ECMAScript\u3001grep\u3001egrep\u3001awk&#xff09;\u7684\u529f\u80fd\u5dee\u5f02&#xff0c;\u8986\u76d6\u5206\u652f\u9009\u62e9\u3001\u951a\u70b9\u3001\u6355\u83b7\u7ec4\u3001\u91cf\u8bcd\u3001\u5404\u7c7b\u8f6c\u4e49\u5b57\u7b26\u3001\u96f6\u5bbd\u65ad\u8a00\u3001\u975e\u8d2a\u5a6a\u5339\u914d\u7b49\u8bed\u6cd5\u7279\u6027&#xff1b;ECMAScript&#xff08;C-regex \u9ed8\u8ba4\u6a21\u5f0f&#xff09;\u652f\u6301\u7684\u9ad8\u7ea7\u529f\u80fd\u6700\u4e3a\u9f50\u5168&#xff0c;basic\u3001grep \u57fa\u7840\u6b63\u5219\u5927\u91cf\u7b26\u53f7\u9700\u8981\u6dfb\u52a0\u53cd\u659c\u6760\u8f6c\u4e49\u3002<\/p>\n<p>\u4e0b\u8868\u6c47\u603b\u5404\u7c7b\u6b63\u5219\u8bed\u6cd5\u6240\u5177\u5907\u7684\u529f\u80fd&#xff1a;<\/p>\n<table>\n<tr>\u8bed\u6cd5\u529f\u80fdbasicextendedECMAScriptgrepegrepawk<\/tr>\n<tbody>\n<tr>\n<td>| \u5145\u5f53\u5206\u652f\u5206\u9694\u7b26<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\\\\n \u5145\u5f53\u5206\u652f\u5206\u9694\u7b26<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u951a\u70b9\u7b26\u53f7<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\u53cd\u5411\u5f15\u7528<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u65b9\u62ec\u53f7\u5b57\u7b26\u96c6<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>() \u6355\u83b7\u5206\u7ec4<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\\\\(\\\\)\u8f6c\u4e49\u6355\u83b7\u5206\u7ec4<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u63a7\u5236\u5b57\u7b26\u8f6c\u4e49\u5e8f\u5217<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>d\/s\/w \u7c7b\u5b57\u7b26\u8f6c\u4e49<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u6587\u4ef6\u683c\u5f0f\u8f6c\u4e49<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\u5341\u516d\u8fdb\u5236\u8f6c\u4e49\u5e8f\u5217<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u666e\u901a\u5b57\u7b26\u8f6c\u4e49&#xff08;\u539f\u6837\u5339\u914d&#xff09;<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\u5426\u5b9a\u578b\u96f6\u5bbd\u65ad\u8a00<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u5355\u8bcd\u5426\u5b9a\u8fb9\u754c\u65ad\u8a00<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u975e\u6355\u83b7\u5206\u7ec4<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u975e\u8d2a\u5a6a\u91cf\u8bcd<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u516b\u8fdb\u5236\u8f6c\u4e49\u5e8f\u5217<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\u666e\u901a\u6587\u672c\u5b57\u7b26<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\u6b63\u5411\u96f6\u5bbd\u65ad\u8a00<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>{} \u91cf\u8bcd\u5199\u6cd5<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\\\\{\\\\} \u8f6c\u4e49\u5f62\u5f0f\u91cf\u8bcd<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>* \u901a\u7528\u91cf\u8bcd<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>?\u3001&#043; \u91cf\u8bcd<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>unicode \u8f6c\u4e49\u5e8f\u5217<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u901a\u914d\u7b26 .<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<td>\u2705\ufe0f<\/td>\n<\/tr>\n<tr>\n<td>\u5355\u8bcd\u8fb9\u754c\u65ad\u8a00<\/td>\n<td><\/td>\n<td><\/td>\n<td>\u2705\ufe0f<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5173\u952e\u70b9\u89e3\u6790<\/p>\n<li>basic-BRE\u3001grep\n<ul>\n<li>\u5c5e\u4e8e\u8001\u65e7\u57fa\u7840\u6b63\u5219&#xff0c;()\u3001{}\u3001| \u5fc5\u987b\u5199\u6210 \\\\(\\\\)\u3001\\\\{\\\\}\u3001\\\\| \u624d\u4f1a\u751f\u6548&#xff0c;\u539f\u751f\u4e0d\u652f\u6301\u975e\u8d2a\u5a6a\u3001\u65ad\u8a00\u3001\u975e\u6355\u83b7\u7ec4\u7b49\u9ad8\u7ea7\u8bed\u6cd5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>extended-ERE\u3001egrep\u3001awk\n<ul>\n<li>\u7b26\u53f7\u4e0d\u9700\u8981\u53cd\u659c\u6760\u8f6c\u4e49&#xff1b;\u7f3a\u5c11\u65ad\u8a00\u3001\u975e\u8d2a\u5a6a\u5339\u914d\u3001Unicode \u8f6c\u4e49&#xff0c;awk \u72ec\u6709\u516b\u8fdb\u5236\u8f6c\u4e49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>ECMAScript&#xff08;C&#043;&#043; std::regex \u9ed8\u8ba4\u6a21\u5f0f&#xff09;\n<ul>\n<li>\u529f\u80fd\u6700\u5b8c\u6574&#xff1a;\u652f\u6301\u65ad\u8a00\u3001\u5355\u8bcd\u8fb9\u754c\u3001\u975e\u8d2a\u5a6a\u91cf\u8bcd\u3001\u975e\u6355\u83b7\u7ec4\u3001\u5404\u7c7b\u8fdb\u5236\u8f6c\u4e49&#xff0c;\u65e5\u5e38\u5f00\u53d1\u4f18\u5148\u9009\u7528\u8be5\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>grep\/egrep \u72ec\u6709&#xff1a;\n<ul>\n<li>\u6362\u884c\u7b26\u53ef\u4ee5\u4ee3\u66ff\u7ad6\u7ebf | \u505a\u5206\u652f\u5206\u9694\u3002<\/li>\n<\/ul>\n<\/li>\n<h2>3 \u8bed\u4e49\u8be6\u7ec6\u4fe1\u606f<\/h2>\n<h3>3.1 \u4f4d\u7f6e\u951a\u70b9<\/h3>\n<p>\u951a\u70b9\u7528\u4e8e\u5339\u914d\u76ee\u6807\u5b57\u7b26\u4e32\u91cc\u7684\u4f4d\u7f6e&#xff0c;\u800c\u975e\u5b57\u7b26\u3002\u8131\u5b57\u7b26 ^ \u5339\u914d\u5b57\u7b26\u4e32\u5f00\u5934&#xff0c;\u7f8e\u5143\u7b26\u53f7 $ \u5339\u914d\u5b57\u7b26\u4e32\u672b\u5c3e\u3002<\/p>\n<p>\u6ce8\u91ca&#xff1a;<\/p>\n<ul>\n<li>\u951a\u70b9\u4e0d\u4f1a\u6d88\u8017\u6587\u672c\u5b57\u7b26&#xff0c;\u53ea\u5224\u5b9a\u5f53\u524d\u6240\u5904\u4f4d\u7f6e&#xff1b;<\/li>\n<li>^ \u8d77\u59cb\u951a\u70b9\u3001$ \u7ed3\u5c3e\u951a\u70b9\u4e3a\u6b63\u5219\u6700\u57fa\u7840\u7684\u8fb9\u754c\u7ea6\u675f\u7b26\u53f7&#xff1b;<\/li>\n<\/ul>\n<h3>3.2 \u53cd\u5411\u5f15\u7528<\/h3>\n<p>\u53cd\u5411\u5f15\u7528\u7531\u53cd\u659c\u6760\u52a0\u4e0a\u5341\u8fdb\u5236\u6570\u5b57 N \u6784\u6210&#xff0c;\u5b83\u4f1a\u5339\u914d\u7b2c N \u4e2a\u6355\u83b7\u5206\u7ec4\u5185\u5b58\u50a8\u7684\u6587\u672c\u5185\u5bb9\u3002\u6570\u5b57 N \u4e0d\u80fd\u8d85\u8fc7\u8be5\u53cd\u5411\u5f15\u7528\u524d\u9762\u5df2\u7ecf\u51fa\u73b0\u8fc7\u7684\u6355\u83b7\u5206\u7ec4\u603b\u6570\u3002<\/p>\n<p>\u5728 basic \u4e0e grep \u8bed\u6cd5\u4e2d&#xff0c;\u4ec5\u8bfb\u53d6\u53cd\u659c\u6760\u540e\u7684\u5355\u4e2a\u5341\u8fdb\u5236\u6570\u5b57\u4f5c\u4e3a\u5206\u7ec4\u7f16\u53f7&#xff1b;\u800c ECMAScript \u4f1a\u8bfb\u53d6\u7d27\u968f\u53cd\u659c\u6760\u4e4b\u540e\u5168\u90e8\u8fde\u7eed\u7684\u6570\u5b57\u3002 \u56e0\u6b64 basic\u3001grep \u6700\u591a\u53ea\u652f\u6301\u7f16\u53f7 1-9 \u7684\u53cd\u5411\u5f15\u7528&#xff0c;\u5373\u4fbf\u8868\u8fbe\u5f0f\u5b58\u5728\u8d85\u8fc7\u4e5d\u4e2a\u6355\u83b7\u7ec4\u3002 ECMAScript \u5219\u6ca1\u6709\u4f4d\u6570\u4e0a\u9650\u3002<\/p>\n<p>\u793a\u4f8b\u89e3\u6790&#xff1a;<\/p>\n<li>((a&#043;)(b&#043;))(c&#043;)\\\\3\n<ul>\n<li>\u80fd\u591f\u5339\u914d\u5b57\u7b26\u4e32 aabbbcbbb\u3002\\\\3 \u5f15\u7528\u7b2c\u4e09\u4e2a\u6355\u83b7\u7ec4 (b&#043;) \u4fdd\u5b58\u7684\u5185\u5bb9&#xff1b;\u65e0\u6cd5\u5339\u914d aabbbcbb\u3002<\/li>\n<\/ul>\n<\/li>\n<li>(a)\\\\2\n<ul>\n<li>\u5c5e\u4e8e\u975e\u6cd5\u5199\u6cd5&#xff0c;\u524d\u9762\u4ec5\u6709 1 \u4e2a\u6355\u83b7\u7ec4&#xff0c;\u4e0d\u5b58\u5728\u4e8c\u53f7\u5206\u7ec4\u3002<\/li>\n<\/ul>\n<\/li>\n<li>(b(((((((((a))))))))))\\\\10\n<ul>\n<li>basic \u6a21\u5f0f&#xff1a;\\\\1 \u4ee3\u8868\u4e00\u53f7\u6355\u83b7\u7ec4 (\u5916\u5c42(b\u2026))&#xff0c;\u672b\u5c3e\u5b57\u7b26 0 \u5f53\u4f5c\u666e\u901a\u5b57\u9762\u5b57\u7b26&#xff1b;<\/li>\n<li>ECMAScript&#xff1a;\\\\10 \u6574\u4f53\u89c6\u4f5c\u5341\u53f7\u6355\u83b7\u7ec4&#xff0c;\u5339\u914d\u6700\u5185\u5c42\u5305\u88f9 a \u7684\u5206\u7ec4&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<p>\u6838\u5fc3\u8981\u70b9<\/p>\n<li>\u53cd\u5411\u5f15\u7528\u4e0d\u5339\u914d\u56fa\u5b9a\u5b57\u7b26&#xff0c;\u800c\u662f\u590d\u7528\u4e4b\u524d\u62ec\u53f7\u6355\u83b7\u5230\u7684\u6587\u672c&#xff1b;<\/li>\n<li>POSIX-basic\/grep&#xff1a;\u4ec5\u652f\u6301 \\\\1~\\\\9&#xff1b;<\/li>\n<li>ECMAScript \u53ef\u8bc6\u522b\u591a\u4f4d\u6570\u7f16\u53f7&#xff0c;\u652f\u6301 \\\\10\u3001\\\\11 \u7b49\u6df1\u5c42\u6355\u83b7\u7ec4&#xff1b;<\/li>\n<h3>3.3 \u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f<\/h3>\n<p>\u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f\u7528\u4e8e\u5b9a\u4e49\u4e00\u7ec4\u5b57\u7b26\u4e0e\u6392\u5e8f\u5143\u7d20\u3002<\/p>\n<ul>\n<li>\u5f53\u8868\u8fbe\u5f0f\u4ee5 ^ \u5f00\u5934\u65f6&#xff0c;\u53ea\u8981\u5f53\u524d\u76ee\u6807\u5b57\u7b26\u4e0d\u5728\u8be5\u5b57\u7b26\u96c6\u5408\u5185&#xff0c;\u5339\u914d\u5c31\u6210\u529f\u3002<\/li>\n<li>\u4e0d\u5e26\u8131\u5b57\u7b26\u65f6&#xff0c;\u53ea\u8981\u76ee\u6807\u5b57\u7b26\u80fd\u591f\u547d\u4e2d\u96c6\u5408\u5f53\u4e2d\u4efb\u610f\u4e00\u4e2a\u5143\u7d20&#xff0c;\u5373\u53ef\u5339\u914d\u6210\u529f\u3002<\/li>\n<\/ul>\n<p>\u96c6\u5408\u5185\u7684\u5b57\u7b26\u53ef\u4ee5\u7531\u591a\u79cd\u5143\u7d20\u81ea\u7531\u7ec4\u5408\u5b9a\u4e49&#xff1a;\u72ec\u7acb\u5b57\u7b26\u3001\u5b57\u7b26\u533a\u95f4\u3001\u5b57\u7b26\u7c7b\u3001\u7b49\u4ef7\u7c7b\u4ee5\u53ca\u6392\u5e8f\u7b26\u53f7\u3002<\/p>\n<p>\u5173\u952e\u89e3\u6790<\/p>\n<li>[abc]&#xff1a;\u5339\u914d a\u3001b\u3001c \u5f53\u4e2d\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26&#xff1b;<\/li>\n<li>[^abc]&#xff1a;\u5339\u914d\u9664 a\u3001b\u3001c \u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26&#xff1b;<\/li>\n<li>\u5185\u90e8\u652f\u6301 &#8211; \u533a\u95f4\u5199\u6cd5 [a-z]\u3001\u5185\u7f6e\u5b57\u7b26\u7c7b\u7b49\u591a\u79cd\u5199\u6cd5&#xff1b;<\/li>\n<h3>3.4 \u6355\u83b7\u7ec4<\/h3>\n<p>\u6355\u83b7\u7ec4\u5c06\u62ec\u53f7\u5185\u7684\u5185\u5bb9\u6807\u8bb0\u6210\u4e00\u4e2a\u6574\u4f53\u5355\u5143&#xff0c;\u540c\u65f6\u4fdd\u5b58\u4e0e\u4e4b\u5339\u914d\u5230\u7684\u76ee\u6807\u5b50\u4e32\u3002 \u6bcf\u4e00\u4e2a\u6355\u83b7\u7ec4\u62e5\u6709\u4e00\u4e2a\u6570\u5b57\u7f16\u53f7&#xff1a;\u6309\u7167\u4ece\u5de6\u5f80\u53f3\u7edf\u8ba1\u5de6\u5706\u62ec\u53f7\u7684\u987a\u5e8f\u8fdb\u884c\u7f16\u53f7\u3002 \u8be5\u6b63\u5219\u5b9e\u73b0\u73af\u5883\u4e0b&#xff0c;\u6355\u83b7\u7ec4\u6570\u91cf\u4e0a\u9650\u4e3a31\u4e2a\u3002<\/p>\n<p>\u793a\u4f8b\u8bf4\u660e&#xff1a;<\/p>\n<li>ab&#043;\n<ul>\n<li>\u53ef\u4ee5\u5339\u914d\u5b57\u7b26\u4e32 abb&#xff0c;\u65e0\u6cd5\u5339\u914d abab&#xff1b;\u52a0\u53f7\u53ea\u4f5c\u7528\u4e8e\u5b57\u7b26 b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>(ab)&#043;\n<ul>\n<li>\u52a0\u53f7\u4f5c\u7528\u4e8e\u6574\u4e2a ab \u5355\u5143&#xff0c;\u80fd\u591f\u91cd\u590d\u5339\u914d&#xff0c;\u547d\u4e2d abab&#xff0c;\u4e0d\u80fd\u5339\u914d abb\u3002<\/li>\n<\/ul>\n<\/li>\n<li>((a&#043;)(b&#043;))(c&#043;)\n<ul>\n<li>\u5339\u914d aabbbc&#xff0c;\u5404\u7ec4\u5bf9\u5e94\u7ed3\u679c&#xff1a;\n<ul>\n<li>1\u53f7\u6355\u83b7\u7ec4&#xff1a;aabbb<\/li>\n<li>2\u53f7\u6355\u83b7\u7ec4&#xff1a;aa<\/li>\n<li>3\u53f7\u6355\u83b7\u7ec4&#xff1a;bbb<\/li>\n<li>4\u53f7\u6355\u83b7\u7ec4&#xff1a;c<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<p>\u6838\u5fc3\u8981\u70b9<\/p>\n<li>\u5706\u62ec\u53f7 () \u517c\u5177\u5206\u7ec4\u548c\u6355\u83b7\u4fdd\u5b58\u5b50\u4e32\u4e24\u79cd\u529f\u80fd&#xff1b;<\/li>\n<li>\u7f16\u53f7\u987a\u5e8f\u53ea\u4f9d\u7167\u5de6\u62ec\u53f7\u4ece\u5de6\u5230\u53f3\u4f9d\u6b21\u8ba1\u6570&#xff0c;\u5d4c\u5957\u62ec\u53f7\u540c\u6837\u9075\u5b88\u8be5\u89c4\u5219&#xff1b;<\/li>\n<li>\u91cf\u8bcd\u4f5c\u7528\u4e8e\u62ec\u53f7\u6574\u4f53\u65f6&#xff0c;\u53ef\u4ee5\u91cd\u590d\u4e00\u6574\u6bb5\u5b57\u7b26\u5e8f\u5217&#xff1b;<\/li>\n<h3>3.5 \u5b57\u7b26\u7c7b<\/h3>\n<p>\u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f\u5185\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u7c7b&#xff0c;\u5b83\u4f1a\u628a\u8be5\u547d\u540d\u7c7b\u522b\u4e0b\u5168\u90e8\u5b57\u7b26\u5f52\u5165\u65b9\u62ec\u53f7\u6240\u5b9a\u4e49\u7684\u5b57\u7b26\u96c6\u5408\u3002\u5b57\u7b26\u7c7b\u8bed\u6cd5\u683c\u5f0f&#xff1a;[:\u7c7b\u540d:]\u3002 \u5e95\u5c42\u5b9e\u73b0\u4f9d\u9760 traits.lookup_classname \u83b7\u53d6\u7c7b\u522b\u7f16\u53f7&#xff1b;\u518d\u901a\u8fc7 traits.isctype(\u5b57\u7b26,\u7f16\u53f7) \u5224\u65ad\u8be5\u5b57\u7b26\u662f\u5426\u5c5e\u4e8e\u5f53\u524d\u5b57\u7b26\u7c7b\u3002<\/p>\n<p>\u6807\u51c6 regex_traits \u6a21\u677f\u652f\u6301\u4e0b\u9762\u6240\u6709\u5185\u7f6e\u5b57\u7b26\u7c7b&#xff1a;<\/p>\n<table>\n<tr>\u7c7b\u540d\u5339\u914d\u8303\u56f4\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>alnum<\/td>\n<td>\u5927\u5c0f\u5199\u5b57\u6bcd &#043; \u6570\u5b57<\/td>\n<\/tr>\n<tr>\n<td>alpha<\/td>\n<td>\u5927\u5c0f\u5199\u5b57\u6bcd<\/td>\n<\/tr>\n<tr>\n<td>blank<\/td>\n<td>\u7a7a\u683c\u3001\u5236\u8868\u7b26<\/td>\n<\/tr>\n<tr>\n<td>cntrl<\/td>\n<td>\u683c\u5f0f\u63a7\u5236\u8f6c\u4e49\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>digit<\/td>\n<td>\u6570\u5b57\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>graph<\/td>\n<td>\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u6807\u70b9&#xff08;\u4e0d\u542b\u7a7a\u683c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>lower<\/td>\n<td>\u5c0f\u5199\u5b57\u6bcd<\/td>\n<\/tr>\n<tr>\n<td>print<\/td>\n<td>\u53ef\u6253\u5370\u5b57\u7b26&#xff1a;\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u6807\u70b9\u3001\u7a7a\u683c<\/td>\n<\/tr>\n<tr>\n<td>punct<\/td>\n<td>\u6807\u70b9\u7b26\u53f7<\/td>\n<\/tr>\n<tr>\n<td>space<\/td>\n<td>\u7a7a\u767d\u5b57\u7b26<\/td>\n<\/tr>\n<tr>\n<td>upper<\/td>\n<td>\u5927\u5199\u5b57\u6bcd<\/td>\n<\/tr>\n<tr>\n<td>xdigit<\/td>\n<td>\u5341\u516d\u8fdb\u5236\u5b57\u7b26 0-9&#xff0c;a-f&#xff0c;A-F<\/td>\n<\/tr>\n<tr>\n<td>d<\/td>\n<td>\u7b49\u4ef7\u4e8e digit&#xff08;\u6570\u5b57&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>s<\/td>\n<td>\u7b49\u4ef7\u4e8e space&#xff08;\u7a7a\u767d&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>w<\/td>\n<td>\u7b49\u4ef7\u4e8e alnum&#xff08;\u5b57\u6bcd\u6570\u5b57&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6838\u5fc3\u8981\u70b9&#xff1a;<\/p>\n<li>\u5b57\u7b26\u7c7b\u53ea\u80fd\u653e\u5728\u65b9\u62ec\u53f7 [] \u91cc\u9762\u4f7f\u7528&#xff0c;\u793a\u4f8b&#xff1a;[[:digit:]]&#xff1b;<\/li>\n<li>d\/s\/w \u5c5e\u4e8e ECMAScript \u98ce\u683c\u7b80\u5199\u522b\u540d&#xff1b;<\/li>\n<li>\u5b57\u7b26\u96c6\u5408\u53d7\u7cfb\u7edf\u672c\u5730\u8bed\u8a00\u73af\u5883&#xff08;locale&#xff09;\u7684\u5f71\u54cd&#xff1b;<\/li>\n<h3>3.6 \u5b57\u7b26\u533a\u95f4<\/h3>\n<p>\u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f\u4e2d\u7684\u5b57\u7b26\u533a\u95f4&#xff0c;\u4f1a\u628a\u533a\u95f4\u5185\u6240\u6709\u5b57\u7b26\u52a0\u5165\u65b9\u62ec\u53f7\u7684\u5b57\u7b26\u96c6\u5408\u3002<\/p>\n<ul>\n<li>\u4e66\u5199\u683c\u5f0f&#xff1a;\u8d77\u59cb\u5b57\u7b26 &#8211; \u7ec8\u6b62\u5b57\u7b26<\/li>\n<li>\u533a\u95f4\u5305\u542b\u7f16\u7801\u6570\u503c\u5927\u4e8e\u7b49\u4e8e\u8d77\u59cb\u5b57\u7b26\u3001\u5c0f\u4e8e\u7b49\u4e8e\u7ec8\u6b62\u5b57\u7b26\u7684\u5168\u90e8\u5b57\u7b26&#xff1b;<\/li>\n<li>\u533a\u95f4\u7ed3\u679c\u53d7\u5e73\u53f0\u5b57\u7b26\u7f16\u7801\u5f71\u54cd&#xff1b;<\/li>\n<li>\u5f53\u77ed\u6a2a\u7ebf &#8211; \u4f4d\u4e8e\u65b9\u62ec\u53f7\u5f00\u5934\u3001\u672b\u5c3e&#xff0c;\u6216\u662f\u533a\u95f4\u8d77\u6b62\u4f4d\u7f6e\u5f02\u5e38\u65f6&#xff0c;- \u4ec5\u4ee3\u8868\u5b83\u81ea\u8eab\u5b57\u9762\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b\u89e3\u8bfb&#xff1a;<\/p>\n<li>[0-7]\n<ul>\n<li>\u5339\u914d\u5b57\u7b26\u96c6\u5408 {0,1,2,3,4,5,6,7}&#xff0c;\u53ea\u80fd\u5339\u914d\u6570\u5b57&#xff0c;\u65e0\u6cd5\u5339\u914d\u5b57\u6bcd a<\/li>\n<\/ul>\n<\/li>\n<li>ASCII \u7f16\u7801\u73af\u5883\u4e0b [h-k]\n<ul>\n<li>\u5305\u542b h\u3001i\u3001j\u3001k<\/li>\n<\/ul>\n<\/li>\n<li>EBCDIC \u7f16\u7801\u73af\u5883\u4e0b [h-k]\n<ul>\n<li>\u7f16\u7801\u4ece 0x88(h) \u5230 0x92(k)&#xff0c;\u4e2d\u95f4\u5939\u5e26\u591a\u4e2a\u4e0d\u53ef\u89c1\u63a7\u5236\u5b57\u7b26&#xff0c;\u533a\u95f4\u5b57\u7b26\u8fdc\u591a\u4e8e h-k \u56db\u4e2a\u5b57\u6bcd\u3002<\/li>\n<\/ul>\n<\/li>\n<li>[-0-24]\n<ul>\n<li>\u96c6\u5408\u5305\u542b\u77ed\u6a2a\u7ebf &#8211; \u30010\u30011\u30012\u30014&#xff1b;\u8fd9\u91cc &#8211; \u5728\u6700\u5f00\u5934&#xff0c;\u4f5c\u4e3a\u666e\u901a\u7b26\u53f7\u3002<\/li>\n<\/ul>\n<\/li>\n<li>[0-2-]\n<ul>\n<li>\u5339\u914d 0\u30011\u30012 \u548c\u77ed\u6a2a\u7ebf &#8211;<\/li>\n<\/ul>\n<\/li>\n<li>ASCII \u73af\u5883 [&#043; &#8211; -]\n<ul>\n<li>\u533a\u95f4\u4ece &#043;(ASCII 43) \u5230 &#8211; (ASCII 45)&#xff0c;\u5305\u542b &#043;\u3001,\u3001-<\/li>\n<\/ul>\n<\/li>\n<p>\u8865\u5145\u89c4\u5219&#xff1a;\u5f00\u542f\u5730\u533a\u8bed\u8a00\u73af\u5883\u540e&#xff0c;\u5b57\u7b26\u533a\u95f4\u4e0d\u518d\u4f9d\u9760\u539f\u59cb\u7f16\u7801\u503c&#xff0c;\u800c\u662f\u6839\u636e\u5f53\u524d\u533a\u57df\u7684\u5b57\u7b26\u6392\u5e8f\u89c4\u5219\u5224\u5b9a\u533a\u95f4\u8303\u56f4\u3002<\/p>\n<p>\u5173\u952e\u8981\u70b9&#xff1a;<\/p>\n<li>&#8211; \u53ea\u6709\u653e\u5728\u4e24\u4e2a\u6709\u6548\u5b57\u7b26\u4e2d\u95f4\u65f6&#xff0c;\u624d\u5145\u5f53\u533a\u95f4\u8fde\u63a5\u7b26&#xff1b;<\/li>\n<li>ASCII\u3001EBCDIC \u7b49\u7f16\u7801\u4e0d\u540c&#xff0c;\u76f8\u540c\u5b57\u7b26\u533a\u95f4\u5f97\u5230\u7684\u5b57\u7b26\u96c6\u5408\u4e0d\u4e00\u6837&#xff1b;<\/li>\n<li>\u672c\u5730\u5316&#xff08;locale&#xff09;\u6a21\u5f0f\u4e0b\u533a\u95f4\u9075\u4ece\u8bed\u8a00\u6392\u5e8f\u89c4\u5219&#xff0c;\u800c\u975e\u5b57\u8282\u7f16\u7801&#xff1b;<\/li>\n<h3>3.7 \u6392\u5e8f\u5143\u7d20<\/h3>\n<p>\u6392\u5e8f\u5143\u7d20\u662f\u88ab\u89c6\u4f5c\u5355\u4e2a\u5b57\u7b26\u7684\u591a\u5b57\u7b26\u5e8f\u5217\u3002<\/p>\n<ul>\n<li>\u6392\u5e8f\u5143\u7d20\u591a\u7528\u4e8e\u90e8\u5206\u672c\u5730\u5316\u73af\u5883&#xff0c;\u628a\u591a\u5b57\u7b26\u5b57\u7b26\u7ec4\u5408\u5f53\u6210\u6574\u4f53\u5339\u914d\u3002<\/li>\n<\/ul>\n<h3>3.8 \u6392\u5e8f\u7b26\u53f7<\/h3>\n<p>\u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f\u5185\u7684\u6392\u5e8f\u7b26\u53f7&#xff0c;\u53ef\u4ee5\u5c06\u4e00\u4e2a\u6392\u5e8f\u5143\u7d20\u52a0\u5165\u8be5\u8868\u8fbe\u5f0f\u5b9a\u4e49\u7684\u5b57\u7b26\u96c6\u5408\u3002<\/p>\n<ul>\n<li>\u4e66\u5199\u683c\u5f0f&#xff1a;[.\u6392\u5e8f\u5143\u7d20.]<\/li>\n<li>[. .] \u4e13\u5c5e POSIX \u6b63\u5219&#xff0c;ECMAScript \u5f15\u64ce\u4e00\u822c\u4e0d\u652f\u6301\u8be5\u5199\u6cd5\u3002<\/li>\n<\/ul>\n<h3>3.9 \u63a7\u5236\u8f6c\u4e49\u5e8f\u5217<\/h3>\n<p>\u63a7\u5236\u8f6c\u4e49\u5e8f\u5217\u7531\u53cd\u659c\u6760\u3001\u5b57\u6bcd c&#xff0c;\u518d\u52a0\u5927\u5c0f\u5199\u82f1\u6587\u5b57\u6bcd\u6784\u6210&#xff1b;\u5b83\u5339\u914d\u8be5\u5b57\u6bcd\u5bf9\u5e94\u7684 ASCII \u63a7\u5236\u5b57\u7b26\u3002<\/p>\n<ul>\n<li>\u4f8b\u5982&#xff1a;\\\\ci \u7b49\u4ef7\u4e8e\u5341\u516d\u8fdb\u5236 \\\\x09&#xff08;\u5236\u8868\u7b26&#xff09;&#xff0c;\u56e0\u4e3a\u5feb\u6377\u952e Ctrl&#043;I \u7684 ASCII \u7f16\u7801\u5c31\u662f 0x09<\/li>\n<li>\\\\cx \u5c5e\u4e8e ECMAScript \u98ce\u683c\u7684\u8f6c\u4e49\u8bed\u6cd5&#xff0c;\u7528\u6765\u5feb\u6377\u8f93\u5165\u5404\u7c7b\u4e0d\u53ef\u89c1\u7684\u63a7\u5236\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<h3>3.10 DSW \u5b57\u7b26\u8f6c\u4e49<\/h3>\n<p>dsw \u5b57\u7b26\u8f6c\u4e49\u662f\u5b57\u7b26\u7c7b\u7684\u77ed\u540d\u79f0&#xff0c;\u5982\u4e0b\u8868\u6240\u793a&#xff1a;<\/p>\n<table>\n<tr>\u8f6c\u4e49\u5e8f\u5217\u7b49\u6548\u547d\u540d\u5b57\u7b26\u7c7b\u9ed8\u8ba4\u5339\u914d\u8303\u56f4&#xff08;ASCII&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\\\\d<\/td>\n<td>[[:d:]]<\/td>\n<td>\u6570\u5b57 [[:digit:]]<\/td>\n<\/tr>\n<tr>\n<td>\\\\D<\/td>\n<td>[^[:d:]]<\/td>\n<td>\u975e\u6570\u5b57 [^[:digit:]]<\/td>\n<\/tr>\n<tr>\n<td>\\\\s<\/td>\n<td>[[:s:]]<\/td>\n<td>\u7a7a\u767d\u5b57\u7b26 [[:space:]]<\/td>\n<\/tr>\n<tr>\n<td>\\\\S<\/td>\n<td>[^[:s:]]<\/td>\n<td>\u975e\u7a7a\u767d\u5b57\u7b26 [^[:space:]]<\/td>\n<\/tr>\n<tr>\n<td>\\\\w<\/td>\n<td>[[:w:]]<\/td>\n<td>\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u4e0b\u5212\u7ebf [a-zA-Z0-9_]<\/td>\n<\/tr>\n<tr>\n<td>\\\\W<\/td>\n<td>[^[:w:]]<\/td>\n<td>\u975e\u5355\u8bcd\u5b57\u7b26 [^a-zA-Z0-9]<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3.11 \u7b49\u4ef7\u7c7b<\/h3>\n<p>\u7b49\u4ef7\u7c7b\u662f POSIX \u6b63\u5219\u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f [] \u5f53\u4e2d\u7684\u672c\u5730\u5316\u5339\u914d\u8bed\u6cd5&#xff0c;\u5199\u6cd5&#xff1a;[&#061;\u5143\u7d20&#061;]\u3002 \u5b83\u53ef\u4ee5\u628a\u6240\u6709\u7b49\u4ef7\u7684\u5b57\u7b26\u3001\u6392\u5e8f\u5143\u7d20\u4e00\u5e76\u5f52\u5165\u5339\u914d\u96c6\u5408&#xff0c;\u591a\u7528\u4e8e\u5ffd\u7565\u91cd\u97f3\u3001\u5927\u5c0f\u5199\u8fd9\u7c7b\u53d8\u4f53\u5b57\u7b26\u3002<\/p>\n<p>\u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f\u5185\u7684\u7b49\u4ef7\u7c7b&#xff0c;\u4f1a\u628a\u6240\u6709\u548c\u5b9a\u4e49\u5143\u7d20\u7b49\u4ef7\u7684\u666e\u901a\u5b57\u7b26\u3001\u6392\u5e8f\u5143\u7d20&#xff0c;\u5168\u90e8\u52a0\u5165\u62ec\u53f7\u8868\u8fbe\u5f0f\u7684\u53ef\u5339\u914d\u5b57\u7b26\u96c6\u5408\u3002<\/p>\n<ul>\n<li>\u7b49\u4ef7\u7c7b\u8bed\u6cd5\u683c\u5f0f&#xff1a;[&#061;\u6392\u5e8f\u5143\u7d20&#061;]<\/li>\n<li>\u5e95\u5c42\u5224\u65ad\u903b\u8f91&#xff1a;\u4e24\u4e2a\u6392\u5e8f\u5143\u7d20 elt1\u3001elt2&#xff0c;\u7ecf\u8fc7 traits.transform_primary \u8f6c\u6362\u4e4b\u540e\u7ed3\u679c\u76f8\u540c&#xff0c;\u5219\u4e8c\u8005\u89c6\u4e3a\u7b49\u4ef7\u3002<\/li>\n<\/ul>\n<p>\u8bf4\u660e&#xff1a;<\/p>\n<li>\u9002\u7528\u5f15\u64ce\n<ul>\n<li>\u4ec5 POSIX \u57fa\u7840 \/ \u6269\u5c55\u6b63\u5219&#xff08;basic\u3001extended&#xff09;\u652f\u6301&#xff1b;<\/li>\n<li>ECMAScript&#xff08;JavaScript \u98ce\u683c&#xff09;\u6b63\u5219\u6ca1\u6709\u8be5\u529f\u80fd&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>transform_primary \u4f5c\u7528\n<ul>\n<li>C&#043;&#043; \u6b63\u5219\u7279\u5f81\u7c7b\u7684\u8be5\u51fd\u6570\u4f1a\u5265\u79bb\u5b57\u7b26\u4fee\u9970\u4fe1\u606f&#xff1a;\u53bb\u6389\u5b57\u6bcd\u91cd\u97f3\u7b26\u53f7\u3001\u5927\u5c0f\u5199\u6807\u8bb0&#xff0c;\u53ea\u4fdd\u7559\u5b57\u7b26\u57fa\u7840\u672c\u4f53\u3002\n<ul>\n<li>\u4f8b\u5982 \u00e1\u3001a\u3001\u00c0 \u7ecf\u8fc7\u8f6c\u6362\u4e4b\u540e\u4e3b\u952e\u4e00\u81f4&#xff0c;[&#061;a&#061;] \u5c31\u80fd\u591f\u5168\u90e8\u5339\u914d\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u548c\u4e4b\u524d\u4e24\u7c7b\u62ec\u53f7\u8bed\u6cd5\u533a\u5206\n<ul>\n<li>[.name.]&#xff1a;\u6392\u5e8f\u7b26\u53f7&#xff0c;\u7528\u6765\u5f55\u5165\u591a\u5b57\u7b26\u6392\u5e8f\u5143\u7d20<\/li>\n<li>[:digit:]&#xff1a;\u5185\u7f6e\u547d\u540d\u5b57\u7b26\u7c7b<\/li>\n<li>[&#061;a&#061;]&#xff1a;\u7b49\u4ef7\u7c7b&#xff0c;\u5339\u914d\u6240\u6709\u5b57\u5f62\u53d8\u4f53\u5b57\u7b26<\/li>\n<\/ul>\n<\/li>\n<li>\u4f7f\u7528\u573a\u666f\n<ul>\n<li>\u9002\u914d\u591a\u56fd\u8bed\u8a00\u3001\u5e26\u91cd\u97f3\u7684\u5916\u6587\u6587\u672c\u6a21\u7cca\u5339\u914d&#xff0c;\u666e\u901a\u82f1\u6587\u5f00\u53d1\u51e0\u4e4e\u7528\u4e0d\u5230\u3002<\/li>\n<\/ul>\n<\/li>\n<h3>3.12 \u6587\u4ef6\u683c\u5f0f\u8f6c\u4e49\u5b57\u7b26<\/h3>\n<p>\u6587\u4ef6\u683c\u5f0f\u8f6c\u4e49\u5c31\u662f C\u8bed\u8a00\u5e38\u89c1\u7684\u5b57\u7b26\u8f6c\u4e49\u5e8f\u5217&#xff1a;\\\\\\\\\u3001\\\\a\u3001\\\\b\u3001\\\\f\u3001\\\\n\u3001\\\\r\u3001\\\\t\u3001\\\\v\u3002 \u5404\u81ea\u542b\u4e49\u4f9d\u6b21\u4e3a&#xff1a;\u53cd\u659c\u6760\u3001\u54cd\u94c3\u3001\u9000\u683c\u3001\u6362\u9875\u3001\u6362\u884c\u3001\u56de\u8f66\u3001\u6c34\u5e73\u5236\u8868\u7b26\u3001\u5782\u76f4\u5236\u8868\u7b26\u3002 \u5728 ECMAScript \u6b63\u5219\u8bed\u6cd5\u4e2d&#xff0c;\\\\a \u548c \\\\b \u4e0d\u88ab\u5f53\u4f5c\u6587\u4ef6\u683c\u5f0f\u8f6c\u4e49&#xff1b;\u53cd\u659c\u6760 \\\\\\\\ \u867d\u7136\u53ef\u7528&#xff0c;\u4f46\u5b83\u5c5e\u4e8e\u6807\u8bc6\u8f6c\u4e49&#xff0c;\u4e0d\u5c5e\u4e8e\u6587\u4ef6\u683c\u5f0f\u8f6c\u4e49\u3002<\/p>\n<li>\u5404\u4e2a\u8f6c\u4e49\u5bf9\u7167\u8868<\/li>\n<table>\n<tr>\u8f6c\u4e49\u7b26\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>\\\\\\\\<\/td>\n<td>\u5b57\u9762\u53cd\u659c\u6760<\/td>\n<\/tr>\n<tr>\n<td>\\\\a<\/td>\n<td>\u8702\u9e23\u54cd\u94c3<\/td>\n<\/tr>\n<tr>\n<td>\\\\b<\/td>\n<td>\u9000\u683c\u952e<\/td>\n<\/tr>\n<tr>\n<td>\\\\f<\/td>\n<td>\u6362\u9875\u7b26<\/td>\n<\/tr>\n<tr>\n<td>\\\\n<\/td>\n<td>\u6362\u884c<\/td>\n<\/tr>\n<tr>\n<td>\\\\r<\/td>\n<td>\u56de\u8f66<\/td>\n<\/tr>\n<tr>\n<td>\\\\t<\/td>\n<td>\u6c34\u5e73 Tab<\/td>\n<\/tr>\n<tr>\n<td>\\\\v<\/td>\n<td>\u5782\u76f4 Tab<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<li>ECMAScript \u6a21\u5f0f\u7279\u6b8a\u89c4\u5219\n<ul>\n<li>\\\\b \u5728 ECMAScript \u91cc\u662f\u5355\u8bcd\u8fb9\u754c\u65ad\u8a00&#xff0c;\u4e0d\u518d\u4ee3\u8868\u9000\u683c\u5b57\u7b26&#xff1b;<\/li>\n<li>\u6ca1\u6709\u54cd\u94c3 \\\\a&#xff1b;<\/li>\n<li>\\\\\\\\ \u4ec5\u7528\u6765\u8f6c\u4e49\u51fa\u5b57\u9762\u53cd\u659c\u6760&#xff0c;\u5f52\u7c7b\u4e3a\u666e\u901a\u6807\u8bc6\u8f6c\u4e49&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>POSIX \u7cfb\u5217\u6b63\u5219&#xff08;basic \/ extended \/ awk \u7b49&#xff09;\n<ul>\n<li>\u5b8c\u6574\u652f\u6301\u4e0a\u9762\u5168\u5957 C-\u98ce\u683c\u63a7\u5236\u5b57\u7b26\u8f6c\u4e49&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<h3>3.13 \u5341\u516d\u8fdb\u5236\u8f6c\u4e49\u5e8f\u5217<\/h3>\n<p>\u5341\u516d\u8fdb\u5236\u8f6c\u4e49\u5e8f\u5217\u7531\u4e00\u4e2a\u53cd\u659c\u6760\u3001\u5b57\u6bcd x&#xff0c;\u518d\u52a0\u4e0a\u4e24\u4f4d\u5341\u516d\u8fdb\u5236\u6570\u5b57&#xff08;0-9\u3001a-f\u3001A-F&#xff09;\u6784\u6210\u3002\u5b83\u5339\u914d\u76ee\u6807\u5b57\u7b26\u4e32\u4e2d&#xff0c;\u7f16\u7801\u503c\u7b49\u4e8e\u8fd9\u4e24\u4f4d\u5341\u516d\u8fdb\u5236\u6570\u6240\u4ee3\u8868\u6570\u503c\u7684\u90a3\u4e2a\u5b57\u7b26\u3002<\/p>\n<ul>\n<li>\u4f8b\u5982&#xff0c;\u4f7f\u7528 ASCII \u7f16\u7801\u65f6&#xff0c;\\\\x41 \u53ef\u4ee5\u5339\u914d\u5b57\u7b26 A<\/li>\n<\/ul>\n<p>\u8981\u70b9\u8bf4\u660e&#xff1a;<\/p>\n<li>\u683c\u5f0f&#xff1a;\\\\xHH&#xff0c;HH \u5fc5\u987b\u6070\u597d 2 \u4f4d\u5341\u516d\u8fdb\u5236&#xff1b;<\/li>\n<li>\u4f5c\u7528&#xff1a;\u901a\u8fc7\u5b57\u7b26\u7684\u5341\u516d\u8fdb\u5236 ASCII \u7801\u76f4\u63a5\u6307\u5b9a\u8981\u5339\u914d\u7684\u5b57\u7b26&#xff1b;<\/li>\n<li>\u5f15\u64ce\u652f\u6301&#xff1a;C&#043;&#043; std::regex \u91cc&#xff0c;\u53ea\u6709 ECMAScript \u8bed\u6cd5\u6a21\u5f0f\u652f\u6301\u8be5\u8f6c\u4e49&#xff1b;basic \/ extended&#xff08;POSIX&#xff09;\u9ed8\u8ba4\u4e0d\u8bc6\u522b \\\\x&#xff1b;<\/li>\n<li>\u6613\u9519\u70b9\n<ul>\n<li>\\\\x41 \u2192 A<\/li>\n<li>\\\\x61 \u2192 a<\/li>\n<li>\u4e0d\u80fd\u53ea\u5199 1 \u4f4d&#xff1a;\\\\xA \u662f\u975e\u6cd5\u5199\u6cd5&#xff0c;\u5fc5\u987b\u5199\u6210 \\\\x0A<\/li>\n<\/ul>\n<\/li>\n<h3>3.14 \u5b57\u9762\u8f6c\u4e49&#xff08;\u6052\u7b49\u8f6c\u4e49 \/ Identity-escape&#xff09;<\/h3>\n<p>\u5b57\u9762\u8f6c\u4e49\u7531\u53cd\u659c\u6760 &#043; \u5355\u4e2a\u5b57\u7b26\u7ec4\u6210&#xff0c;\u76f4\u63a5\u5339\u914d\u8be5\u5b57\u7b26\u672c\u8eab\u3002 \u5f53\u67d0\u4e2a\u5b57\u7b26\u5728\u6b63\u5219\u91cc\u62e5\u6709\u7279\u6b8a\u542b\u4e49\u65f6&#xff0c;\u5c31\u9700\u8981\u4f7f\u7528\u5b57\u9762\u8f6c\u4e49&#xff1b;\u52a0\u4e0a\u53cd\u659c\u6760\u4e4b\u540e&#xff0c;\u8be5\u5b57\u7b26\u4f1a\u5931\u53bb\u7279\u6b8a\u529f\u80fd&#xff0c;\u53d8\u56de\u666e\u901a\u5b57\u7b26\u3002<\/p>\n<ul>\n<li>a* \u53ef\u4ee5\u5339\u914d \u201caaa\u201d&#xff0c;\u4e0d\u80fd\u5339\u914d \u201ca*\u201d<\/li>\n<li>a\\\\* \u4e0d\u80fd\u5339\u914d \u201caaa\u201d&#xff0c;\u53ef\u4ee5\u5339\u914d \u201ca*\u201d<\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u505a\u5b57\u9762\u8f6c\u4e49\u7684\u5b57\u7b26\u96c6\u5408&#xff0c;\u968f\u6b63\u5219\u8bed\u6cd5\u6a21\u5f0f\u4e0d\u540c\u800c\u53d8\u5316&#xff1a;<\/p>\n<table>\n<tr>\u8bed\u6cd5\u5141\u8bb8\u7684\u6807\u8bc6\u8f6c\u4e49\u5b57\u7b26<\/tr>\n<tbody>\n<tr>\n<td>basic\u3001grep<\/td>\n<td>{ ( ) { } . [ \\\\ * ^ $ }<\/td>\n<\/tr>\n<tr>\n<td>extended\u3001egrep<\/td>\n<td>{ ( ) { . [ \\\\ * ^ $ &#043; ? | }<\/td>\n<\/tr>\n<tr>\n<td>awk<\/td>\n<td>\u5728 extended \u57fa\u7840\u4e0a\u989d\u5916\u652f\u6301 &#034; \/<\/td>\n<\/tr>\n<tr>\n<td>ECMAScript<\/td>\n<td>\u9664\u6807\u8bc6\u7b26\u5b57\u7b26&#xff08;\u5b57\u6bcd\u3001\u6570\u5b57 \u3001$\u3001_\u3001Unicode \u8f6c\u4e49&#xff09;\u5916&#xff0c;\u5176\u4f59\u6240\u6709\u5b57\u7b26\u90fd\u53ef\u4f7f\u7528\u5b57\u9762\u8f6c\u4e49<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8981\u70b9\u8bf4\u660e<\/p>\n<li>\u672c\u8d28\u4f5c\u7528&#xff1a;\\\\\u5143\u5b57\u7b26 \u2192 \u666e\u901a\u5b57\u7b26&#xff0c;\u53d6\u6d88\u5143\u5b57\u7b26\u7279\u6b8a\u8bed\u4e49<\/li>\n<li>\u540d\u79f0&#xff1a;Identity escape&#xff0c;\u6807\u51c6\u53eb\u6cd5 \u6052\u7b49\u8f6c\u4e49 \/ \u5b57\u9762\u8f6c\u4e49<\/li>\n<li>\u8de8\u6a21\u5f0f\u5751\u70b9\n<ul>\n<li>\u540c\u6837\u5199 \\\\&#043;&#xff0c;\u5728 basic-POSIX \u53ef\u80fd\u62a5\u9519&#xff0c;basic \u91cc &#043; \u672c\u8eab\u4e0d\u662f\u5143\u5b57\u7b26&#xff0c;\u4e0d\u80fd\u968f\u4fbf\u52a0\u53cd\u659c\u6760\u8f6c\u4e49&#xff1b;ECMAScript \u51e0\u4e4e\u53ef\u4ee5\u968f\u4fbf\u53cd\u659c\u6760\u8f6c\u4e49\u7b26\u53f7&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>C&#043;&#043; regex \u9ed8\u8ba4\u6a21\u5f0f\u662f ECMAScript&#xff0c;\u56e0\u6b64 \\\\* \\\\&#043; \\\\? \\\\| \u90fd\u53ef\u4ee5\u6b63\u5e38\u7528\u6765\u8f6c\u4e49&#xff1b;<\/li>\n<h3>3.15 \u666e\u901a\u5b57\u7b26&#xff08;Individual character&#xff09;<\/h3>\n<p>\u65b9\u62ec\u53f7\u8868\u8fbe\u5f0f\u91cc\u53ef\u4ee5\u76f4\u63a5\u4e66\u5199\u5355\u4e2a\u5b57\u7b26&#xff0c;\u8be5\u5b57\u7b26\u5c31\u4f1a\u88ab\u52a0\u5165\u65b9\u62ec\u53f7\u5b9a\u4e49\u7684\u5b57\u7b26\u96c6\u5408\u3002 ^ \u653e\u5728\u65b9\u62ec\u53f7\u975e\u5f00\u5934\u7684\u4f4d\u7f6e\u65f6&#xff0c;\u4ec5\u4ee3\u8868\u5b57\u7b26\u672c\u8eab&#xff0c;\u4e0d\u5145\u5f53\u53d6\u53cd\u5143\u5b57\u7b26\u3002 \u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>[abc]&#xff1a;\u53ef\u4ee5\u5339\u914d a\u3001b\u3001c&#xff0c;\u4e0d\u80fd\u5339\u914d d<\/li>\n<li>[^abc]&#xff1a;\u53d6\u53cd&#xff0c;\u53ef\u4ee5\u5339\u914d d&#xff0c;\u4e0d\u80fd\u5339\u914d a\u3001b\u3001c<\/li>\n<li>[a^bc]&#xff1a;^\u4e0d\u662f\u9996\u5b57\u7b26&#xff0c;\u4f5c\u4e3a\u666e\u901a\u5b57\u7b26&#xff0c;\u53ef\u5339\u914d a\u3001b\u3001c\u3001^&#xff0c;\u4e0d\u80fd\u5339\u914d d<\/li>\n<\/ul>\n<p>\u9664 ECMAScript \u4ee5\u5916\u7684\u5168\u90e8\u6b63\u5219\u8bed\u6cd5&#xff1a; \u5982\u679c ] \u7d27\u8ddf\u5728\u5de6\u62ec\u53f7 [ \u540e\u9762\u3001\u6216\u8005\u7d27\u8ddf\u5728\u5f00\u5934\u53d6\u53cd\u7b26 ^ \u4e4b\u540e&#xff0c;] \u88ab\u5f53\u4f5c\u666e\u901a\u5b57\u9762\u5b57\u7b26&#xff0c;\u800c\u4e0d\u662f\u65b9\u62ec\u53f7\u7684\u7ed3\u675f\u6807\u8bb0\u3002 \u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>[]a&#xff1a;\u975e\u6cd5&#xff0c;\u7f3a\u5c11\u7528\u6765\u95ed\u5408\u7684 ]<\/li>\n<li>[]abc]&#xff1a;\u96c6\u5408\u5305\u542b ]\u3001a\u3001b\u3001c<\/li>\n<li>[^]abc]&#xff1a;\u53d6\u53cd\u96c6\u5408&#xff0c;\u5339\u914d\u9664 ]\u3001a\u3001b\u3001c \u4ee5\u5916\u5b57\u7b26<\/li>\n<\/ul>\n<p>ECMAScript \u8bed\u6cd5\u89c4\u5219\u4e0d\u4e00\u6837&#xff1a; \u65b9\u62ec\u53f7\u5185\u90e8\u60f3\u8981\u8868\u793a\u5b57\u9762\u7684 ]\u3001\u5fc5\u987b\u8f6c\u4e49\u5199\u6210 ] \u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>[]a&#xff1a;\u65b9\u62ec\u53f7\u5185\u90e8\u4e3a\u7a7a\u96c6\u5408&#xff0c;\u53ea\u80fd\u5339\u914d a<\/li>\n<li>[\\\\]abc]&#xff1a;\u96c6\u5408\u5305\u542b ]\u3001a\u3001b\u3001c<\/li>\n<\/ul>\n<p>\u8981\u70b9\u603b\u7ed3<\/p>\n<li>^ \u53ea\u6709\u4f4d\u4e8e [ \u4e4b\u540e\u7b2c\u4e00\u4f4d\u624d\u4ee3\u8868\u53d6\u53cd&#xff0c;\u5176\u4f59\u5730\u65b9\u5c31\u662f\u666e\u901a\u8131\u5b57\u7b26<\/li>\n<li>POSIX \u7cfb\u5217\u8bed\u6cd5&#xff08;basic \/ extended \/ grep \/ egrep \/ awk&#xff09;&#xff1a;] \u653e\u5728\u62ec\u53f7\u6700\u524d\u9762\u4e0d\u9700\u8981\u8f6c\u4e49<\/li>\n<li>ECMAScript&#xff08;C&#043;&#043;\u6b63\u5219\u9ed8\u8ba4\u6a21\u5f0f&#xff09;&#xff1a;] \u5728 [] \u91cc\u9762\u5fc5\u987b\u8f6c\u4e49 \\\\]&#xff0c;\u5426\u5219\u8bed\u6cd5\u51fa\u9519<\/li>\n<h3>3.16 \u8d1f\u5411\u65ad\u8a00<\/h3>\n<p>\u8d1f\u5411\u65ad\u8a00\u5339\u914d\u4e0d\u6ee1\u8db3\u62ec\u53f7\u5185\u89c4\u5219\u7684\u4f4d\u7f6e\u3002\u5b83\u4e0d\u4f1a\u6d88\u8017\u76ee\u6807\u5b57\u7b26\u4e32\u91cc\u7684\u4efb\u4f55\u5b57\u7b26\u3002 \u793a\u4f8b&#xff1a;(!aa)(a*)<\/p>\n<ul>\n<li>\u53ef\u4ee5\u5339\u914d\u5b57\u7b26\u4e32 \u201ca\u201d&#xff0c;\u6355\u83b7\u7ec4 1 \u62ff\u5230\u5b50\u4e32 \u201ca\u201d&#xff1b;<\/li>\n<li>\u4e0d\u80fd\u5339\u914d \u201caa\u201d\u3001\u201caaa\u201d&#xff1b;<\/li>\n<li>\u6587\u6863\u91cc (!aa) \u662f ECMAScript \u98ce\u683c\u8d1f\u5148\u884c\u65ad\u8a00 (?!aa) \u7684\u7b80\u5199\u5199\u6cd5&#xff1b;<\/li>\n<\/ul>\n<p>\u6838\u5fc3&#xff1a;<\/p>\n<li>\u96f6\u5bbd\u5ea6&#xff1a;\u65ad\u8a00\u672c\u8eab\u53ea\u68c0\u67e5\u6761\u4ef6&#xff0c;\u4e0d\u541e\u6389\u5b57\u7b26&#xff0c;\u5339\u914d\u4f4d\u7f6e\u4e0d\u4f1a\u5411\u540e\u79fb\u52a8&#xff1b;<\/li>\n<li>\u8d1f\u5148\u884c\u542b\u4e49&#xff08;?!aa&#xff09;&#xff1a;\u5f53\u524d\u4f4d\u7f6e\u540e\u9762\u4e0d\u80fd\u7d27\u8ddf\u7740 aa&#xff1b;<\/li>\n<li>\u62c6\u89e3\u4f8b\u5b50 (?!aa)(a*)\n<ul>\n<li>(?!aa)&#xff1a;\u68c0\u67e5\u5f53\u524d\u4f4d\u7f6e\u4e4b\u540e&#xff0c;\u4e0d\u662f\u4e24\u4e2a\u8fde\u7eed a<\/li>\n<li>(a*)&#xff1a;\u7136\u540e\u6355\u83b7\u5c3d\u53ef\u80fd\u591a\u7684 a<\/li>\n<li>\u201ca\u201d&#xff1a;\u5f53\u524d\u4f4d\u7f6e\u540e\u9762\u53ea\u6709 1 \u4e2a a&#xff0c;\u6ee1\u8db3\u65ad\u8a00&#xff0c;\u6210\u529f\u5339\u914d<\/li>\n<li>\u201caa\u201d&#xff1a;\u5f00\u5934\u540e\u9762\u5c31\u662f aa&#xff0c;\u8d1f\u65ad\u8a00\u5931\u8d25&#xff0c;\u6574\u4f53\u65e0\u6cd5\u5339\u914d<\/li>\n<\/ul>\n<\/li>\n<p>\u6ce8&#xff1a;<\/p>\n<ul>\n<li>\u53ea\u6709 ECMAScript \u8bed\u6cd5\u652f\u6301 (?!) \u8d1f\u5148\u884c\u65ad\u8a00&#xff1b;<\/li>\n<li>POSIX (basic \/ extended \/ grep \/ awk) \u8bed\u6cd5\u4e0d\u652f\u6301\u96f6\u5bbd\u65ad\u8a00&#xff1b;<\/li>\n<\/ul>\n<h3>3.17 \u8d1f\u5411\u5355\u8bcd\u8fb9\u754c\u65ad\u8a00&#xff08;Negative word boundary assert&#xff09;<\/h3>\n<p>\u5f53\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u5f53\u524d\u4f4d\u7f6e\u4e0d\u5728\u5355\u8bcd\u8fb9\u754c\u5904\u65f6&#xff0c;\u65ad\u8a00\u5339\u914d\u6210\u529f\u3002<\/p>\n<p>\u6838\u5fc3&#xff1a;<\/p>\n<li>\u5c5e\u4e8e\u96f6\u5bbd\u5ea6\u65ad\u8a00&#xff0c;\u53ea\u5224\u65ad\u4f4d\u7f6e&#xff0c;\u4e0d\u6d88\u8017\u4efb\u4f55\u5b57\u7b26&#xff1b;<\/li>\n<li>\u5355\u8bcd\u8fb9\u754c \\\\b&#xff1a;\u4e00\u8fb9\u662f\u5355\u8bcd\u5b57\u7b26 [a-zA-Z0-9_]\u3001\u53e6\u4e00\u8fb9\u662f\u975e\u5355\u8bcd\u5b57\u7b26<\/li>\n<li>\u8d1f\u5355\u8bcd\u8fb9\u754c\u5143\u5b57\u7b26&#xff1a;\\\\B\n<ul>\n<li>\\\\b &#061; \u662f\u5355\u8bcd\u8fb9\u754c<\/li>\n<li>\\\\B &#061; \u4e0d\u662f\u5355\u8bcd\u8fb9\u754c<\/li>\n<\/ul>\n<\/li>\n<p>\u793a\u4f8b&#xff1a;\u5b57\u7b26\u4e32 apple<\/p>\n<ul>\n<li>a \u524d\u9762&#xff1a;\u8fb9\u754c \u2192 \\\\b \u6210\u7acb&#xff0c;\\\\B \u5931\u8d25<\/li>\n<li>a \u548c p \u4e4b\u95f4&#xff1a;\u4e24\u4e2a\u90fd\u662f\u5355\u8bcd\u5b57\u7b26 \u2192 \u4e0d\u662f\u8fb9\u754c&#xff0c;\\\\B \u5339\u914d\u6210\u529f<\/li>\n<\/ul>\n<p>C&#043;&#043; regex \u9650\u5236 \u4ec5 ECMAScript \u6a21\u5f0f\u652f\u6301 \\\\b \/ \\\\B \u5355\u8bcd\u8fb9\u754c&#xff0c;POSIX \u8bed\u6cd5\u4e0d\u63d0\u4f9b\u5355\u8bcd\u8fb9\u754c\u65ad\u8a00\u3002<\/p>\n<h3>3.18 \u975e\u6355\u83b7\u7ec4&#xff08;Non-capture group&#xff09;<\/h3>\n<p>\u975e\u6355\u83b7\u7ec4\u53ef\u4ee5\u628a\u62ec\u53f7\u5185\u6574\u4f53\u5f53\u6210\u4e00\u4e2a\u903b\u8f91\u5355\u5143&#xff0c;\u4f46\u662f\u4e0d\u4f1a\u5206\u914d\u7f16\u53f7\u3001\u4e0d\u4fdd\u5b58\u5339\u914d\u5230\u7684\u6587\u672c\u3002<\/p>\n<p>\u793a\u4f8b&#xff1a;(a)(?:b)*(c) \u5339\u914d\u5b57\u7b26\u4e32 \u201cabbc\u201d<\/p>\n<ul>\n<li>\u6355\u83b7\u7ec4 1&#xff1a;a<\/li>\n<li>\u6355\u83b7\u7ec4 2&#xff1a;c<\/li>\n<li>(?:b)* &#xff1a;\u53ea\u7528\u6765\u5206\u7ec4\u3001\u652f\u6301\u91cf\u8bcd * \u91cd\u590d&#xff0c;\u4e0d\u4f1a\u751f\u6210\u6355\u83b7\u7f16\u53f7\u3002<\/li>\n<\/ul>\n<p>\u6838\u5fc3<\/p>\n<li>\u8bed\u6cd5&#xff1a;(?:\u5b50\u8868\u8fbe\u5f0f)<\/li>\n<li>\u548c\u666e\u901a\u6355\u83b7\u7ec4 () \u76f8\u540c\u70b9\n<ul>\n<li>\u6539\u53d8\u8fd0\u7b97\u4f18\u5148\u7ea7<\/li>\n<li>\u53ef\u4ee5\u76f4\u63a5\u540e\u9762\u52a0\u91cf\u8bcd * &#043; ? {m,n}<\/li>\n<\/ul>\n<\/li>\n<li>\u548c\u666e\u901a\u6355\u83b7\u7ec4 () \u4e0d\u540c\u70b9\n<ul>\n<li>\u4e0d\u5360\u7528\u6355\u83b7\u7f16\u53f7<\/li>\n<li>\u5339\u914d\u7ed3\u679c\u4e0d\u4f1a\u5b58\u5230 match \u5206\u7ec4\u91cc<\/li>\n<li>\u8f7b\u5fae\u8282\u7701\u5185\u5b58\u3001\u63d0\u5347\u4e00\u70b9\u6027\u80fd<\/li>\n<\/ul>\n<\/li>\n<li>\u4f8b\u5b50\u62c6\u89e3 (a)(?:b)*(c)\n<ul>\n<li>(a)&#xff1a;\u6355\u83b7\u7ec4 #1&#xff0c;\u4fdd\u5b58 a<\/li>\n<li>(?:b)*&#xff1a;\u628a b \u6253\u5305&#xff0c;\u53ef\u4ee5\u91cd\u590d\u96f6\u6b21\u6216\u591a\u6b21&#xff0c;\u4e0d\u4ea7\u751f\u5206\u7ec4<\/li>\n<li>(c)&#xff1a;\u6355\u83b7\u7ec4 #2&#xff0c;\u4fdd\u5b58 c<\/li>\n<\/ul>\n<\/li>\n<p>C&#043;&#043; regex \u8bed\u6cd5\u652f\u6301<\/p>\n<ul>\n<li>\u53ea\u6709 ECMAScript \u6a21\u5f0f\u652f\u6301 (?:\u2026) \u975e\u6355\u83b7\u7ec4&#xff1b;<\/li>\n<li>POSIX&#xff08;basic \/ extended \/ grep \/ awk&#xff09;\u6ca1\u6709\u975e\u6355\u83b7\u7ec4\u8bed\u6cd5&#xff1b;<\/li>\n<\/ul>\n<h3>3.19 \u975e\u8d2a\u5a6a\u91cd\u590d<\/h3>\n<p>\u975e\u8d2a\u5a6a\u91cf\u8bcd\u4f1a\u5339\u914d\u76ee\u6807\u5b57\u7b26\u4e32\u4e2d\u6ee1\u8db3\u6761\u4ef6\u7684\u6700\u77ed\u5b50\u4e32&#xff1b;\u8d2a\u5a6a\u91cf\u8bcd\u5219\u5339\u914d\u6ee1\u8db3\u6761\u4ef6\u7684\u6700\u957f\u5b50\u4e32\u3002 \u4e3e\u4e2a\u4f8b\u5b50&#xff1a;(a&#043;)(a*b) \u53ef\u4ee5\u5339\u914d\u5b57\u7b26\u4e32 \u201caaab\u201d\u3002<\/p>\n<ul>\n<li>\u4f7f\u7528\u975e\u8d2a\u5a6a\u6a21\u5f0f\u65f6&#xff1a;\u6355\u83b7\u7ec4 1 \u5339\u914d \u201ca\u201d&#xff0c;\u6355\u83b7\u7ec4 2 \u5339\u914d \u201caab\u201d<\/li>\n<li>\u4f7f\u7528\u8d2a\u5a6a\u6a21\u5f0f\u65f6&#xff1a;\u6355\u83b7\u7ec4 1 \u5339\u914d \u201caaa\u201d&#xff0c;\u6355\u83b7\u7ec4 2 \u5339\u914d \u201cb\u201d<\/li>\n<\/ul>\n<p>\u8981\u70b9\u89e3\u6790<\/p>\n<li>\u8d2a\u5a6a&#xff08;greedy&#xff09;\n<ul>\n<li>\u9ed8\u8ba4\u884c\u4e3a&#xff0c;&#043;\u3001*\u3001? \u3001{m,n} \u90fd\u662f\u8d2a\u5a6a&#xff0c;\u5c3d\u53ef\u80fd\u591a\u5403\u5b57\u7b26&#xff1b;<\/li>\n<li>(a&#043;)(a*b) \u8d2a\u5a6a&#xff1a;a&#043; \u62ff\u8d70\u5c3d\u53ef\u80fd\u591a a \u2192 aaa&#xff0c;\u5269\u4e0b b \u4ea4\u7ed9\u7b2c\u4e8c\u7ec4&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u975e\u8d2a\u5a6a&#xff08;non-greedy\/lazy&#xff09;\n<ul>\n<li>\u5728\u91cf\u8bcd\u540e\u9762\u52a0 ? \u5f00\u542f&#xff1a;&#043;?\u3001*?\u3001??\u3001{m,n}?<\/li>\n<li>\u6539\u6210\u975e\u8d2a\u5a6a\u5199\u6cd5&#xff1a;(a&#043;?)(a*b)<\/li>\n<li>a&#043;? \u5148\u62ff\u6700\u5c11 1 \u4e2a a&#xff0c;\u5269\u4e0b aab \u4ea4\u7ed9\u7b2c\u4e8c\u7ec4\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u8bed\u6cd5\u652f\u6301&#xff08;C&#043;&#043; std::regex&#xff09;\n<ul>\n<li>\u2705\ufe0fECMAScript&#xff1a;\u5b8c\u6574\u652f\u6301\u975e\u8d2a\u5a6a &#043;?\u3001*?\u3001??\u3001{m,n}?<\/li>\n<li>\u274c\ufe0fbasic \/ extended \/ grep \/ egrep \/ awk&#xff1a;\u6ca1\u6709\u975e\u8d2a\u5a6a\u91cf\u8bcd<\/li>\n<\/ul>\n<\/li>\n<h3>3.20 \u516b\u8fdb\u5236\u8f6c\u4e49\u5e8f\u5217&#xff08;Octal escape sequence&#xff09;<\/h3>\n<p>\u516b\u8fdb\u5236\u8f6c\u4e49\u5e8f\u5217\u7531\u4e00\u4e2a\u53cd\u659c\u6760&#xff0c;\u540e\u9762\u7d27\u8ddf 1-3 \u4f4d\u516b\u8fdb\u5236\u6570\u5b57 0-7 \u7ec4\u6210\u3002\u5b83\u53ef\u4ee5\u5339\u914d\u76ee\u6807\u5b57\u7b26\u4e32\u4e2d&#xff0c;\u7b49\u4e8e\u8be5\u516b\u8fdb\u5236\u6570\u503c\u7684\u5b57\u7b26\u3002 \u5982\u679c\u5168\u90e8\u6570\u5b57\u90fd\u662f0&#xff0c;\u5219\u8be5\u8f6c\u4e49\u5e8f\u5217\u65e0\u6548&#xff1b;<\/p>\n<ul>\n<li>\u793a\u4f8b&#xff1a;\u5728 ASCII \u7f16\u7801\u4e0b&#xff0c;\\\\101 \u5339\u914d\u5b57\u7b26 A<\/li>\n<\/ul>\n<p>\u8981\u70b9\u8bf4\u660e<\/p>\n<li>\u8bed\u6cd5&#xff1a;\\\\ &#043; 1~3 \u4e2a\u6570\u5b57&#xff08;0-7&#xff09;\n<ul>\n<li>\\\\0&#xff1a;\u274c\ufe0f\u5168\u96f6&#xff0c;\u975e\u6cd5<\/li>\n<li>\\\\65&#xff1a;\u2705\ufe0f1~3\u4f4d\u516b\u8fdb\u5236<\/li>\n<li>\\\\101&#xff1a;\u2705\ufe0f1~3\u4f4d\u516b\u8fdb\u5236<\/li>\n<\/ul>\n<\/li>\n<li>\u5339\u914d\u89c4\u5219&#xff1a;\u628a\u516b\u8fdb\u5236\u6570\u8f6c\u4e3a\u5341\u8fdb\u5236&#xff0c;\u53d6\u5bf9\u5e94 ASCII \u5b57\u7b26\n<ul>\n<li>\\\\101 &#061; \u516b\u8fdb\u5236 101 &#061; \u5341\u8fdb\u5236 65 &#061; \u2018A\u2019<\/li>\n<\/ul>\n<\/li>\n<li>\u4f4d\u6570\u4e0a\u9650&#xff1a;\u6700\u591a\u8bfb\u53d6 3 \u4f4d\u516b\u8fdb\u5236\u6570\u5b57&#xff0c;\u8d85\u8fc7\u5c31\u4e0d\u518d\u89e3\u6790<\/li>\n<li>\u8bed\u6cd5\u652f\u6301&#xff1a;C&#043;&#043; \u6b63\u5219\u4ec5 ECMAScript \u6a21\u5f0f\u652f\u6301\u516b\u8fdb\u5236\u8f6c\u4e49&#xff1b;POSIX(basic \/ extended) \u4e0d\u652f\u6301<\/li>\n<h3>3.21 \u666e\u901a\u5b57\u7b26&#xff08;Ordinary character&#xff09;<\/h3>\n<p>\u666e\u901a\u5b57\u7b26\u662f\u5728\u5f53\u524d\u6b63\u5219\u8bed\u6cd5\u89c4\u5219\u4e0b\u3001\u4e0d\u5177\u5907\u7279\u6b8a\u542b\u4e49\u7684\u4efb\u610f\u6709\u6548\u5b57\u7b26\u3002<\/p>\n<ul>\n<li>\u5728 ECMAScript \u6a21\u5f0f\u4e2d&#xff0c;\u4ee5\u4e0b\u5b57\u7b26\u62e5\u6709\u7279\u6b8a\u8bed\u4e49&#xff1a;\n<ul>\n<li>^ $ \\\\ . * &#043; ? ( ) [ ] { } |<\/li>\n<\/ul>\n<\/li>\n<li>\u5728 basic\u3001grep \u6a21\u5f0f\u4e2d&#xff0c;\u4ee5\u4e0b\u5b57\u7b26\u6c38\u4e45\u62e5\u6709\u7279\u6b8a\u8bed\u4e49&#xff1a;\n<ul>\n<li>. [ \\\\<\/li>\n<\/ul>\n<\/li>\n<li>\u540c\u65f6\u5728 basic\u3001grep \u6a21\u5f0f\u91cc&#xff0c;\u4e0b\u9762\u8fd9\u4e9b\u5b57\u7b26\u4ec5\u5728\u7279\u5b9a\u4e0a\u4e0b\u6587\u624d\u6709\u7279\u6b8a\u542b\u4e49&#xff1a;\n<ul>\n<li>*&#xff1a;\u7edd\u5927\u591a\u6570\u573a\u666f\u6709\u7279\u6b8a\u542b\u4e49&#xff1b;\u53ea\u6709\u4f4d\u4e8e\u6b63\u5219\u5f00\u5934\u3001^ \u4e4b\u540e\u3001\u6355\u83b7\u7ec4\u5f00\u5934\u3001\u6355\u83b7\u7ec4\u5185 ^ \u4e4b\u540e\u65f6&#xff0c;*\u4f5c\u4e3a\u666e\u901a\u5b57\u7b26<\/li>\n<li>^&#xff1a;\u4ec5\u5f53\u5b83\u4f4d\u4e8e\u6574\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u7b2c\u4e00\u4e2a\u5b57\u7b26\u65f6\u624d\u662f\u951a\u70b9\u5143\u5b57\u7b26<\/li>\n<li>$&#xff1a;\u4ec5\u5f53\u5b83\u4f4d\u4e8e\u6574\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u65f6\u624d\u662f\u951a\u70b9\u5143\u5b57\u7b26<\/li>\n<\/ul>\n<\/li>\n<li>\u5728 extended\u3001egrep\u3001awk \u6a21\u5f0f\u4e2d&#xff0c;\u6c38\u4e45\u7279\u6b8a\u5b57\u7b26&#xff1a;\n<ul>\n<li>. [ \\\\ ( * &#043; ? { |<\/li>\n<\/ul>\n<\/li>\n<li>extended \/ egrep \/ awk \u6a21\u5f0f\u4e0b&#xff0c;\u4e0a\u4e0b\u6587\u654f\u611f\u5b57\u7b26&#xff1a;\n<ul>\n<li>)&#xff1a;\u53ea\u6709\u524d\u9762\u5b58\u5728\u5bf9\u5e94\u7684 ( \u65f6\u624d\u6709\u5206\u7ec4\u53f3\u62ec\u53f7\u542b\u4e49<\/li>\n<li>^&#xff1a;\u4ec5\u5728\u6b63\u5219\u9996\u4f4d\u4f5c\u4e3a\u884c\u5f00\u5934\u951a\u70b9<\/li>\n<li>$&#xff1a;\u4ec5\u5728\u6b63\u5219\u672b\u5c3e\u4f5c\u4e3a\u884c\u7ed3\u5c3e\u951a\u70b9<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u666e\u901a\u5b57\u7b26\u4f1a\u76f4\u63a5\u5339\u914d\u76ee\u6807\u5b57\u7b26\u4e32\u4e2d\u5b8c\u5168\u4e00\u6837\u7684\u5b57\u7b26&#xff1a;<\/p>\n<ul>\n<li>\u9ed8\u8ba4\u533a\u5206\u5927\u5c0f\u5199&#xff1a;\u4e24\u4e2a\u5b57\u7b26\u7f16\u7801\u503c\u76f8\u7b49\u624d\u7b97\u5339\u914d\u6210\u529f<\/li>\n<li>\u5ffd\u7565\u5927\u5c0f\u5199\u5339\u914d&#xff1a;\u901a\u8fc7 traits.translate_nocase(ch0) &#061;&#061; traits.translate_nocase(ch1) \u5224\u65ad<\/li>\n<li>\u533a\u57df\u8bed\u8a00(locale)\u654f\u611f\u5339\u914d&#xff1a;\u901a\u8fc7 traits.translate(ch0) &#061;&#061; traits.translate(ch1) \u5224\u65ad<\/li>\n<\/ul>\n<p>\u6838\u5fc3\u8981\u70b9<\/p>\n<li>\u4e00\u4e2a\u5b57\u7b26\u662f\u4e0d\u662f\u5143\u5b57\u7b26&#xff0c;\u53d6\u51b3\u4e8e\u4f60\u9009\u62e9\u54ea\u4e00\u79cd\u6b63\u5219\u8bed\u6cd5&#xff0c;\u4e0d\u540c\u6a21\u5f0f\u7279\u6b8a\u5b57\u7b26\u5217\u8868\u4e0d\u4e00\u6837<\/li>\n<li>basic \/ grep&#xff08;BRE&#xff09;\u5f88\u591a\u7b26\u53f7\u662f\u4e0a\u4e0b\u6587\u5143\u5b57\u7b26&#xff0c;\u4e0d\u5728\u7279\u5b9a\u4f4d\u7f6e\u5c31\u53d8\u56de\u666e\u901a\u5b57\u7b26&#xff0c;\u8fd9\u662f POSIX-BRE \u6700\u5bb9\u6613\u8e29\u5751\u7684\u5730\u65b9<\/li>\n<li>\u4e09\u79cd\u5339\u914d\u6a21\u5f0f\n<ul>\n<li>\u9ed8\u8ba4&#xff1a;\u7cbe\u786e\u4e8c\u8fdb\u5236\u7f16\u7801\u76f8\u7b49<\/li>\n<li>\u4e0d\u533a\u5206\u5927\u5c0f\u5199&#xff1a;\u8c03\u7528 translate_nocase \u8f6c\u6362\u540e\u6bd4\u8f83<\/li>\n<li>\u672c\u5730\u5316\u5339\u914d&#xff1a;\u8c03\u7528 translate&#xff0c;\u53d7\u5f53\u524d locale \u5f71\u54cd<\/li>\n<\/ul>\n<\/li>\n<h3>3.22 \u6b63\u5411\u65ad\u8a00&#xff08;Positive assert&#xff09;<\/h3>\n<p>\u6b63\u5411\u65ad\u8a00\u53ef\u4ee5\u5339\u914d\u5b83\u5185\u90e8\u7684\u5b50\u6a21\u5f0f&#xff0c;\u4f46\u4e0d\u4f1a\u6d88\u8017\u76ee\u6807\u5b57\u7b26\u4e32\u4e2d\u7684\u4efb\u4f55\u5b57\u7b26\u3002 \u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>(&#061;aa)(a*) \u53ef\u4ee5\u5339\u914d \u201caaaa\u201d&#xff0c;\u6355\u83b7\u7ec4 1 \u5339\u914d \u201caaaa\u201d\u3002<\/li>\n<li>(aa)(a*) \u53ef\u4ee5\u5339\u914d \u201caaaa\u201d&#xff0c;\u6355\u83b7\u7ec4 1 \u5339\u914d\u5f00\u5934\u7684 \u201caa\u201d&#xff0c;\u6355\u83b7\u7ec4 2 \u5339\u914d\u672b\u5c3e\u7684 \u201caa\u201d\u3002<\/li>\n<li>(&#061;aa)(a)|(a) \u53ef\u4ee5\u5339\u914d \u201ca\u201d&#xff1a;\u6b63\u5411\u65ad\u8a00\u5339\u914d\u5931\u8d25&#xff0c;\u6355\u83b7\u7ec4 1 \u5f97\u5230\u7a7a\u4e32&#xff0c;\u6355\u83b7\u7ec4 2 \u5339\u914d \u201ca\u201d\u3002\n<ul>\n<li>\u8be5\u8868\u8fbe\u5f0f\u4e5f\u53ef\u4ee5\u5339\u914d \u201caa\u201d&#xff1a;\u6355\u83b7\u7ec4 1 \u5339\u914d \u201caa\u201d&#xff0c;\u6355\u83b7\u7ec4 2 \u5f97\u5230\u7a7a\u4e32\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u8981\u70b9\u8bf4\u660e<\/p>\n<li>\u96f6\u5bbd\u5ea6&#xff08;\u6700\u91cd\u8981&#xff09;\n<ul>\n<li>\u65ad\u8a00\u53ea\u68c0\u67e5\u4f4d\u7f6e\u540e\u9762\u80fd\u4e0d\u80fd\u5339\u914d\u4e0a&#xff0c;\u5339\u914d\u6210\u529f\u4e4b\u540e&#xff0c;\u6b63\u5219\u5149\u6807\u7684\u4f4d\u7f6e\u4e0d\u4f1a\u5411\u540e\u79fb\u52a8&#xff0c;\u540e\u9762\u7684\u6a21\u5f0f\u4ecd\u7136\u4ece\u5f53\u524d\u4f4d\u7f6e\u5f00\u59cb\u5339\u914d\u3002\n<ul>\n<li>\u666e\u901a\u5206\u7ec4 (aa)&#xff1a;\u5403\u6389\u4e24\u4e2a\u5b57\u7b26&#xff0c;\u5149\u6807\u524d\u8fdb 2 \u4f4d&#xff1b;<\/li>\n<li>\u6b63\u5411\u65ad\u8a00 (&#061;aa)&#xff1a;\u53ea\u505a\u68c0\u6d4b&#xff0c;\u5149\u6807\u539f\u5730\u4e0d\u52a8&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u8bed\u6cd5\u8bf4\u660e\n<ul>\n<li>\u26a0\ufe0f\u5fae\u8f6f\u6587\u6863\u8fd9\u91cc\u7528 (&#061;pattern) \u8868\u793a\u6b63\u5411\u5148\u884c\u65ad\u8a00<\/li>\n<li>\u6807\u51c6 ECMAScript \u5199\u6cd5\u662f (?&#061;pattern)&#xff0c;C&#043;&#043; std::regex ECMAScript \u6a21\u5f0f\u652f\u6301 (?&#061;\u2026)<\/li>\n<\/ul>\n<\/li>\n<li>\u548c\u666e\u901a\u6355\u83b7\u7ec4 (aa) \u7684\u5bf9\u6bd4<\/li>\n<ul>\n<li>(aa)&#xff1a;\u6d88\u8017\u5b57\u7b26&#xff0c;\u5339\u914d\u5230\u7684 \u201caa\u201d \u5b58\u5165\u6355\u83b7\u7ec4&#xff0c;\u5149\u6807\u5f80\u540e\u8d70<\/li>\n<li>(?&#061;aa)&#xff1a;\u4e0d\u6d88\u8017\u5b57\u7b26&#xff0c;\u4ec5\u6821\u9a8c\u540e\u9762\u662f\u4e0d\u662f aa&#xff0c;\u5149\u6807\u7559\u5728\u539f\u5730<\/li>\n<\/ul>\n<li>\u5339\u914d\u903b\u8f91\u62c6\u89e3\u7b2c\u4e00\u4e2a\u4f8b\u5b50 (?&#061;aa)(a*)&#xff0c;\u76ee\u6807\u4e32 \u201caaaa\u201d\n<ul>\n<li>\u5728\u8d77\u59cb\u4f4d\u7f6e&#xff0c;\u5148\u68c0\u67e5\u540e\u9762\u662f\u4e0d\u662f aa \u2192 \u901a\u8fc7&#xff08;\u65ad\u8a00\u6210\u529f&#xff09;&#xff0c;\u5149\u6807\u4e0d\u52a8<\/li>\n<li>\u63a5\u7740\u6267\u884c a*&#xff0c;\u4ece\u5f53\u524d\u4f4d\u7f6e\u5c3d\u53ef\u80fd\u5403\u6389\u6240\u6709 a&#xff0c;\u62ff\u5230 aaaa<\/li>\n<\/ul>\n<\/li>\n<li>\u652f\u6301\u60c5\u51b5\n<ul>\n<li>\u53ea\u6709 ECMAScript \u8bed\u6cd5\u652f\u6301\u6b63\u5411 \/ \u8d1f\u5411\u65ad\u8a00&#xff1b;basic \/ extended \/ grep \/ egrep \/ awk \u6ca1\u6709\u65ad\u8a00\u529f\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<h3>3.23 Unicode \u8f6c\u4e49\u5e8f\u5217&#xff08;Unicode escape sequence&#xff09;<\/h3>\n<p>Unicode \u8f6c\u4e49\u5e8f\u5217\u683c\u5f0f&#xff1a;\u53cd\u659c\u6760 \\\\ &#043; \u5b57\u6bcd u &#043; 4 \u4f4d\u5341\u516d\u8fdb\u5236\u6570\u5b57 0-9 a-f A-F\u3002 \u5b83\u5339\u914d\u76ee\u6807\u5b57\u7b26\u4e32\u4e2d\u7801\u70b9\u7b49\u4e8e\u8fd9 4 \u4f4d\u5341\u516d\u8fdb\u5236\u6570\u503c\u7684\u5b57\u7b26\u3002 \u793a\u4f8b&#xff1a;ASCII \u7f16\u7801\u73af\u5883\u4e0b&#xff0c;\\\\u0041 \u5339\u914d\u5b57\u7b26 \u201cA\u201d<\/p>\n<p>\u8981\u70b9\u8be6\u89e3<\/p>\n<li>\u8bed\u6cd5\u683c\u5f0f\n<ul>\n<li>\\\\uXXXX<\/li>\n<li>XXXX\u5fc5\u987b\u662f\u6070\u597d 4 \u4e2a\u5341\u516d\u8fdb\u5236\u5b57\u7b26&#xff0c;\u8303\u56f4 0000 &#8211; FFFF&#xff0c;\u53ea\u80fd\u8868\u793a BMP \u5e73\u9762&#xff08;U&#043;0000~U&#043;FFFF&#xff09;\u3002<\/li>\n<li>\u26a0\ufe0f&#xff1a;std::regex ECMAScript \u6a21\u5f0f\u91cc&#xff0c;\\\\u \u4e0d\u652f\u6301 \\\\uXXXXXXXX 8\u4f4d\u683c\u5f0f&#xff08;\u8865\u5145\u5e73\u9762\u5b57\u7b26&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\u539f\u7406\n<ul>\n<li>\u628a 4 \u4f4d\u5341\u516d\u8fdb\u5236\u8f6c\u4e3a Unicode \u7801\u70b9&#xff0c;\u5339\u914d\u5bf9\u5e94\u5b57\u7b26<\/li>\n<li>\\\\u0041 \u2192 \u7801\u70b9 U&#043;0041 \u2192 &#039;A&#039;<\/li>\n<li>\\\\u4E2D \u2192 U&#043;4E2D \u2192 \u6c49\u5b57 \u4e2d<\/li>\n<\/ul>\n<\/li>\n<li>\u8bed\u6cd5\u5f15\u64ce\u652f\u6301\n<ul>\n<li>\u2705\ufe0fECMAScript&#xff1a;\u652f\u6301 \\\\uXXXX<\/li>\n<li>\u274c\ufe0fbasic \/ extended \/ grep \/ egrep \/ awk&#xff1a;\u4e0d\u652f\u6301 Unicode \u8f6c\u4e49<\/li>\n<\/ul>\n<\/li>\n<li>C&#043;&#043;\u4ee3\u7801\u5c0f\u63d0\u9192\n<ul>\n<li>C&#043;&#043;\u5b57\u7b26\u4e32\u672c\u8eab\u53cd\u659c\u6760\u9700\u8981\u8f6c\u4e49&#xff0c;\u6b63\u5219\u91cc\u5199 \\\\u0041&#xff0c;C&#043;&#043;\u6e90\u7801\u5b57\u7b26\u4e32\u5fc5\u987b\u5199\u6210 \\\\\\\\u0041<\/li>\n<\/ul>\n<\/li>\n<h3>3.24 \u901a\u914d\u7b26&#xff08;Wildcard character&#xff0c;. \u70b9\u53f7&#xff09;<\/h3>\n<p>\u901a\u914d\u7b26 . \u53ef\u4ee5\u5339\u914d\u76ee\u6807\u5b57\u7b26\u4e32\u91cc\u9664\u6362\u884c\u7b26\u4ee5\u5916\u7684\u4efb\u610f\u5355\u4e2a\u5b57\u7b26\u3002<\/p>\n<p>\u8981\u70b9\u8bf4\u660e<\/p>\n<li>\u57fa\u7840\u89c4\u5219\n<ul>\n<li>. \u2260 \u771f\u6b63\u610f\u4e49\u4e0a\u7684 \u201c\u6240\u6709\u5b57\u7b26\u201d&#xff0c;\u9ed8\u8ba4\u4e0d\u80fd\u5339\u914d \\\\n \u6362\u884c&#xff1b;\n<ul>\n<li>\u4f8b&#xff1a;\u6b63\u5219 a.b\n<ul>\n<li>\u201caab\u201d&#xff1a;\u2705\ufe0f\u5339\u914d<\/li>\n<li>\u201caxb\u201d&#xff1a;\u2705\ufe0f\u5339\u914d<\/li>\n<li>\u201ca\\\\nb\u201d&#xff1a;\u274c\ufe0f\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5339\u914d\u5931\u8d25<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>C&#043;&#043; std::regex \u5f00\u542f\u70b9\u53f7\u5339\u914d\u6362\u884c\n<ul>\n<li>ECMAScript \u8bed\u6cd5\u4e0b&#xff0c;\u8bbe\u7f6e\u6807\u5fd7 regex_constants::dotall&#xff0c;. \u5c31\u53ef\u4ee5\u5305\u542b\u6362\u884c\u7b26 \\\\n<\/li>\n<\/ul>\n<\/li>\n<li>\u4e0d\u540c\u6b63\u5219\u6a21\u5f0f\u5747\u652f\u6301 .\n<ul>\n<li>basic \/ extended \/ ECMAScript \/ grep \/ egrep \/ awk \u5168\u90e8\u652f\u6301\u70b9\u901a\u914d\u7b26<\/li>\n<\/ul>\n<\/li>\n<li>\u5982\u679c\u9700\u8981\u5b57\u9762 .\n<ul>\n<li>\u5fc5\u987b\u8f6c\u4e49 \\\\.&#xff0c;\u5426\u5219\u4f1a\u88ab\u5f53\u6210\u901a\u914d\u7b26<\/li>\n<\/ul>\n<\/li>\n<h3>3.25 \u5355\u8bcd\u8fb9\u754c&#xff08;Word boundary&#xff0c;\\\\b&#xff09;<\/h3>\n<p>\u5355\u8bcd\u8fb9\u754c\u51fa\u73b0\u5728\u4e0b\u9762\u56db\u79cd\u4f4d\u7f6e\u4e4b\u4e00&#xff1a;<\/p>\n<li>\u5f53\u524d\u4f4d\u7f6e\u662f\u76ee\u6807\u5b57\u7b26\u4e32\u5f00\u5934&#xff0c;\u5e76\u4e14\u9996\u5b57\u7b26\u5c5e\u4e8e\u5355\u8bcd\u5b57\u7b26 A-Z a-z 0-9 _<\/li>\n<li>\u5f53\u524d\u4f4d\u7f6e\u5728\u76ee\u6807\u5b57\u7b26\u4e32\u672b\u5c3e\u4e4b\u540e&#xff0c;\u5e76\u4e14\u5b57\u7b26\u4e32\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u662f\u5355\u8bcd\u5b57\u7b26<\/li>\n<li>\u5f53\u524d\u5b57\u7b26\u662f\u5355\u8bcd\u5b57\u7b26&#xff0c;\u524d\u4e00\u4e2a\u5b57\u7b26\u4e0d\u662f\u5355\u8bcd\u5b57\u7b26<\/li>\n<li>\u5f53\u524d\u5b57\u7b26\u4e0d\u662f\u5355\u8bcd\u5b57\u7b26&#xff0c;\u524d\u4e00\u4e2a\u5b57\u7b26\u662f\u5355\u8bcd\u5b57\u7b26<\/li>\n<p>\u8981\u70b9\u8be6\u89e3<\/p>\n<li>\u96f6\u5bbd\u5ea6\u65ad\u8a00\n<ul>\n<li>\\\\b \u53ea\u5339\u914d\u4f4d\u7f6e&#xff0c;\u4e0d\u6d88\u8017\u4efb\u4f55\u5b57\u7b26&#xff0c;\u4e0d\u4f1a\u541e\u6389\u5b57\u7b26\u4e32\u91cc\u7684\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5355\u8bcd\u5b57\u7b26\u5b9a\u4e49\n<ul>\n<li>[A-Z a-z 0-9 _]<\/li>\n<li>\u4e0b\u5212\u7ebf _ \u5c5e\u4e8e\u5355\u8bcd\u5b57\u7b26&#xff0c;\u8fd9\u70b9\u5f88\u5bb9\u6613\u8e29\u5751&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u8fb9\u754c\u672c\u8d28&#xff1a;\u5355\u8bcd\u5b57\u7b26 \u2194 \u975e\u5355\u8bcd\u5b57\u7b26 \u7684\u4ea4\u754c\u5904\n<ul>\n<li>abc def&#xff1a;c \u548c\u7a7a\u683c\u4e4b\u95f4\u3001\u7a7a\u683c\u548c d \u4e4b\u95f4\u90fd\u5b58\u5728\u5355\u8bcd\u8fb9\u754c<\/li>\n<li>hello_world&#xff1a;\u4e2d\u95f4 _ \u4e24\u8fb9\u6ca1\u6709\u8fb9\u754c&#xff0c;\u56e0\u4e3a\u4e0b\u5212\u7ebf\u5c5e\u4e8e\u5355\u8bcd\u5b57\u7b26<\/li>\n<\/ul>\n<\/li>\n<li>\u652f\u6301\u60c5\u51b5\n<ul>\n<li>\u4ec5 ECMAScript \u6a21\u5f0f\u652f\u6301 \\\\b \/ \\\\B&#xff0c;POSIX&#xff08;basic \/ extended \/ grep \u2026&#xff09;\u4e0d\u63d0\u4f9b\u5355\u8bcd\u8fb9\u754c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u53cd\u4e49&#xff1a;\\\\B\n<ul>\n<li>\u975e\u5355\u8bcd\u8fb9\u754c&#xff0c;\u5339\u914d\u4e0d\u662f\u5355\u8bcd\u8fb9\u754c\u7684\u4f4d\u7f6e\u3002<\/li>\n<li>\u793a\u4f8b&#xff1a;\u6b63\u5219 \\\\bcat\\\\b\n<ul>\n<li>&#034;cat&#034;\u2705\ufe0f<\/li>\n<li>&#034;my cat.&#034;\u2705\ufe0f<\/li>\n<li>&#034;category&#034;\u274c\ufe0f&#xff08;cat \u540e\u9762\u7d27\u8ddf\u7740\u5b57\u6bcd&#xff0c;\u65e0\u8fb9\u754c&#xff09;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<h3>3.26 \u5355\u8bcd\u8fb9\u754c\u65ad\u8a00&#xff08;Word boundary assert&#xff0c;\\\\b&#xff09;<\/h3>\n<p>\u5f53\u76ee\u6807\u5b57\u7b26\u4e32\u7684\u5f53\u524d\u4f4d\u7f6e\u6b63\u597d\u5904\u4e8e\u4e00\u4e2a\u5355\u8bcd\u8fb9\u754c\u4e4b\u540e\u65f6&#xff0c;\u5355\u8bcd\u8fb9\u754c\u65ad\u8a00\u5339\u914d\u6210\u529f\u3002<\/p>\n<p>\u8981\u70b9\u89e3\u6790<\/p>\n<li>\u96f6\u5bbd\u5ea6\n<ul>\n<li>\\\\b \u662f\u4f4d\u7f6e\u65ad\u8a00&#xff0c;\u4e0d\u6d88\u8017\u4efb\u4f55\u5b57\u7b26&#xff0c;\u53ea\u68c0\u6d4b\u5f53\u524d\u5149\u6807\u6240\u5728\u4f4d\u7f6e\u662f\u4e0d\u662f\u5355\u8bcd\u8fb9\u754c\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5355\u8bcd\u8fb9\u754c\u5224\u65ad\u6807\u51c6&#xff08;\u56de\u987e&#xff09;\n<ul>\n<li>\u5355\u8bcd\u5b57\u7b26&#xff1a;A-Z a-z 0-9 _<\/li>\n<li>\u8fb9\u754c\u53d1\u751f\u5728&#xff1a;\n<ul>\n<li>\u5b57\u7b26\u4e32\u5f00\u5934 &#043; \u540e\u9762\u662f\u5355\u8bcd\u5b57\u7b26<\/li>\n<li>\u5b57\u7b26\u4e32\u7ed3\u5c3e &#043; \u524d\u9762\u662f\u5355\u8bcd\u5b57\u7b26<\/li>\n<li>\u5355\u8bcd\u5b57\u7b26 \u2194 \u975e\u5355\u8bcd\u5b57\u7b26\u7684\u4ea4\u754c\u5904<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\\\\b \u548c \\\\B\n<ul>\n<li>\\\\b&#xff1a;\u5339\u914d\u5355\u8bcd\u8fb9\u754c\u4f4d\u7f6e<\/li>\n<li>\\\\B&#xff1a;\u5339\u914d\u975e\u5355\u8bcd\u8fb9\u754c\u4f4d\u7f6e&#xff08;\u8fb9\u754c\u4e0d\u6210\u7acb\u7684\u4f4d\u7f6e&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\u5f15\u64ce\u652f\u6301\n<ul>\n<li>\u4ec5 ECMAScript \u8bed\u6cd5\u652f\u6301 \\\\b \/ \\\\B&#xff1b;<\/li>\n<li>basic\u3001extended\u3001grep\u3001egrep\u3001awk \u6ca1\u6709\u5355\u8bcd\u8fb9\u754c&#xff1b;<\/li>\n<\/ul>\n<\/li>\n<li>\u793a\u4f8b\n<ul>\n<li>\u5b57\u7b26\u4e32&#xff1a;test,abc\n<ul>\n<li>\u4f4d\u7f6e\u5728 t \u524d\u9762\u3001t-e \u4e4b\u95f4\u3001e-s \u4e4b\u95f4\u3001s-t \u4e4b\u95f4\u3001t \u548c , \u4e4b\u95f4\u3001, \u548c a \u4e4b\u95f4\u3001a-b \u4e4b\u95f4\u3001b-c \u4e4b\u95f4\u3001c \u672b\u5c3e<\/li>\n<li>\u5176\u4e2d\u5355\u8bcd\u8fb9\u754c&#xff1a;^t\u3001t,\u3001,a\u3001c$<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<h2>4 \u5339\u914d\u4e0e\u641c\u7d22<\/h2>\n<p>\u5b8c\u6574\u5339\u914d&#xff08;match&#xff09;&#xff1a;\u6b63\u5219\u8868\u8fbe\u5f0f\u5fc5\u987b\u5339\u914d\u6574\u4e2a\u76ee\u6807\u5b57\u7b26\u4e32\u624d\u7b97\u5339\u914d\u6210\u529f\u3002<\/p>\n<ul>\n<li>\u4f8b\u5982\u6b63\u5219 bcd&#xff0c;\u53ef\u4ee5\u5339\u914d \u201cbcd\u201d&#xff1b;\u4e0d\u80fd\u5339\u914d \u201cabcd\u201d&#xff0c;\u4e5f\u4e0d\u80fd\u5339\u914d \u201cbcde\u201d\u3002<\/li>\n<\/ul>\n<p>\u641c\u7d22\u67e5\u627e&#xff08;search&#xff09;&#xff1a;\u53ea\u8981\u76ee\u6807\u5b57\u7b26\u4e32\u4e2d\u67d0\u5904\u5b58\u5728\u4e00\u6bb5\u5b50\u4e32\u80fd\u591f\u5339\u914d\u6b63\u5219&#xff0c;\u67e5\u627e\u5c31\u6210\u529f\u3002\u67e5\u627e\u901a\u5e38\u4f18\u5148\u627e\u5230\u6700\u9760\u5de6\u7684\u5339\u914d\u9879\u3002 \u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>\u5728 \u201cbcd\u201d \u4e2d\u641c\u7d22 bcd&#xff1a;\u67e5\u627e\u6210\u529f&#xff0c;\u5339\u914d\u6574\u4e2a\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u5728 \u201cabcd\u201d \u4e2d\u641c\u7d22 bcd&#xff1a;\u67e5\u627e\u6210\u529f&#xff0c;\u5339\u914d\u6700\u540e\u4e09\u4e2a\u5b57\u7b26\u3002<\/li>\n<li>\u5728 \u201cbcde\u201d \u4e2d\u641c\u7d22 bcd&#xff1a;\u67e5\u627e\u6210\u529f&#xff0c;\u5339\u914d\u5f00\u5934\u4e09\u4e2a\u5b57\u7b26\u3002<\/li>\n<li>\u5728 \u201cbcdbcd\u201d \u4e2d\u641c\u7d22 bcd&#xff1a;\u67e5\u627e\u6210\u529f&#xff0c;\u5339\u914d\u6700\u9760\u524d\u7684\u524d\u4e09\u4e2a\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<p>\u5982\u679c\u5728\u540c\u4e00\u4e2a\u8d77\u59cb\u4f4d\u7f6e\u53ef\u4ee5\u5339\u914d\u51fa\u591a\u4e2a\u4e0d\u540c\u5b50\u4e32&#xff0c;\u6709\u4e24\u79cd\u9009\u62e9\u7b56\u7565&#xff1a;<\/p>\n<li>\u4f18\u5148\u5339\u914d&#xff08;first-match&#xff09;&#xff1a;\u5206\u652f | \u4ece\u5de6\u5411\u53f3\u5c1d\u8bd5&#xff0c;\u4e00\u65e6\u5de6\u8fb9\u5206\u652f\u5339\u914d\u6210\u529f&#xff0c;\u76f4\u63a5\u8fd4\u56de&#xff0c;\u4e0d\u518d\u6d4b\u8bd5\u53f3\u4fa7\u5206\u652f\u3002<\/li>\n<li>\u6700\u957f\u5339\u914d&#xff08;longest-match&#xff09;&#xff1a;\u5728\u6240\u6709\u53ef\u884c\u7684\u5b50\u5339\u914d\u91cc\u9762\u9009\u51fa\u957f\u5ea6\u6700\u957f\u7684\u90a3\u4e00\u4e2a&#xff1b;\u957f\u5ea6\u76f8\u540c\u5219\u4f18\u5148\u9009\u62e9\u5148\u627e\u5230\u7684\u3002<\/li>\n<p>\u4e3e\u4f8b&#xff1a;\u6b63\u5219 b|bc&#xff0c;\u76ee\u6807\u4e32 \u201cabcd\u201d<\/p>\n<ul>\n<li>first-match&#xff08;ECMAScript&#xff09;&#xff1a;\u5148\u5339\u914d b \u6210\u529f&#xff0c;\u76f4\u63a5\u8fd4\u56de\u5b50\u4e32 \u201cb\u201d&#xff0c;\u4e0d\u4f1a\u518d\u5c1d\u8bd5 bc<\/li>\n<li>longest-match&#xff08;POSIX-extended \/ egrep \/ awk&#xff09;&#xff1a;\u5019\u9009 \u201cb\u201d\u3001\u201cbc\u201d&#xff0c;\u9009\u62e9\u66f4\u957f\u7684 \u201cbc\u201d<\/li>\n<\/ul>\n<p>\u90e8\u5206\u5339\u914d&#xff08;partial match&#xff09;&#xff1a;\u5373\u4f7f\u6b63\u5219\u8fd8\u6ca1\u6709\u89e3\u6790\u5b8c\u6bd5&#xff0c;\u53ea\u8981\u5df2\u7ecf\u8d70\u5230\u76ee\u6807\u5b57\u7b26\u4e32\u672b\u5c3e\u4e14\u4e2d\u9014\u6ca1\u6709\u5339\u914d\u5931\u8d25&#xff0c;\u90e8\u5206\u5339\u914d\u5c31\u89c6\u4e3a\u6210\u529f\u3002 \u56e0\u6b64&#xff1a;<\/p>\n<ul>\n<li>\u90e8\u5206\u5339\u914d\u6210\u529f\u4e4b\u540e&#xff0c;\u5982\u679c\u7ed9\u76ee\u6807\u5b57\u7b26\u4e32\u8ffd\u52a0\u5b57\u7b26&#xff0c;\u540e\u7eed\u518d\u6b21\u505a\u90e8\u5206\u5339\u914d\u6709\u53ef\u80fd\u5931\u8d25&#xff1b;<\/li>\n<li>\u5982\u679c\u5f53\u524d\u90e8\u5206\u5339\u914d\u5df2\u7ecf\u5931\u8d25&#xff0c;\u5c31\u7b97\u518d\u8ffd\u52a0\u5b57\u7b26&#xff0c;\u540e\u7eed\u4e5f\u4e0d\u53ef\u80fd\u53d8\u6210\u90e8\u5206\u5339\u914d\u6210\u529f&#xff1b;<\/li>\n<\/ul>\n<p>\u4f8b\u5b50&#xff1a;\u5f00\u542f\u90e8\u5206\u5339\u914d\u6a21\u5f0f\u65f6&#xff0c;ab \u53ef\u4ee5\u90e8\u5206\u5339\u914d \u201ca\u201d&#xff1b;\u4e0d\u80fd\u90e8\u5206\u5339\u914d \u201cac\u201d\u3002<\/p>\n<p>\u6838\u5fc3\u8981\u70b9&#xff08;C&#043;&#043; std::regex&#xff09;<\/p>\n<li>regex_match \u2192 \u5b8c\u6574\u5339\u914d\n<ul>\n<li>\u8981\u6c42\u6b63\u5219\u8986\u76d6\u5168\u90e8\u8f93\u5165\u5b57\u7b26\u4e32&#xff0c;\u7b49\u4ef7\u4e8e\u81ea\u52a8\u9690\u5f0f\u52a0\u4e0a ^\u2026$<\/li>\n<\/ul>\n<\/li>\n<p> <span class=\"token comment\">\/\/ &#034;abcd&#034; \u4e0d\u80fd\u5339\u914d &#034;bcd&#034;<\/span><br \/>\n<span class=\"token function\">regex_match<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;abcd&#034;<\/span><span class=\"token punctuation\">,<\/span> sm<span class=\"token punctuation\">,<\/span> <span class=\"token function\">regex<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;bcd&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> \u2192 <span class=\"token boolean\">false<\/span><\/p>\n<li>regex_search \u2192 \u5b50\u4e32\u641c\u7d22\n<ul>\n<li>\u5728\u5b57\u7b26\u4e32\u4efb\u610f\u4f4d\u7f6e\u67e5\u627e&#xff0c;\u627e\u5230\u6700\u5de6\u4fa7\u5339\u914d<\/li>\n<\/ul>\n<\/li>\n<p> <span class=\"token function\">regex_search<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;abcd&#034;<\/span><span class=\"token punctuation\">,<\/span> sm<span class=\"token punctuation\">,<\/span> <span class=\"token function\">regex<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;bcd&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> \u2192 <span class=\"token boolean\">true<\/span><\/p>\n<li>\u5206\u652f\u9009\u62e9\u7b56\u7565\u5dee\u5f02&#xff08;|&#xff09;\n<ul>\n<li>ECMAScript&#xff1a;First-match \u4f18\u5148\u5339\u914d&#xff0c;\u5de6\u8fb9\u5206\u652f\u547d\u4e2d\u5373\u505c\u6b62<\/li>\n<li>POSIX extended \/ egrep \/ awk&#xff1a;Longest-match \u6700\u957f\u4f18\u5148<\/li>\n<\/ul>\n<\/li>\n<li>\u90e8\u5206\u5339\u914d\n<ul>\n<li>C&#043;&#043;\u901a\u8fc7 match_partial \u6807\u5fd7\u5b9e\u73b0&#xff0c;\u7528\u4e8e\u6d41\u5f0f\u3001\u622a\u65ad\u5b57\u7b26\u4e32\u573a\u666f&#xff0c;\u666e\u901a\u6b63\u5219\u5f88\u5c11\u7528\u5230\u3002<\/li>\n<\/ul>\n<\/li>\n<h2>5 \u683c\u5f0f\u6807\u5fd7 \/ \u66ff\u6362\u6587\u672c\u5360\u4f4d\u7b26&#xff08;ECMAScript \u66ff\u6362\u89c4\u5219&#xff09;<\/h2>\n<p>\u4ec5 ECMAScript \u8bed\u6cd5\u652f\u6301\u4e0b\u9762\u8fd9\u4e9b $ \u5f00\u5934\u7684\u66ff\u6362\u5360\u4f4d\u7b26&#xff0c;\u7528\u4e8e regex_replace \u7684\u66ff\u6362\u5b57\u7b26\u4e32<\/p>\n<table>\n<tr>\u5360\u4f4d\u7b26\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>$&amp;<\/td>\n<td>\u6574\u4e2a\u6b63\u5219\u5b8c\u6574\u5339\u914d\u5230\u7684\u5b50\u4e32&#xff08;\u5bf9\u5e94\u7b2c 0 \u53f7\u6355\u83b7\u7ec4&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>$&#096;<\/td>\n<td>\u5339\u914d\u9879\u524d\u9762\u7684\u5168\u90e8\u6587\u672c&#xff08;\u524d\u7f00&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>$\u2019<\/td>\n<td>\u5339\u914d\u9879\u540e\u9762\u7684\u5168\u90e8\u6587\u672c&#xff08;\u540e\u7f00&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>$n<\/td>\n<td>\u7f16\u53f7 0-9 \u7684\u6355\u83b7\u7ec4&#xff0c;n \u662f 1 \u4f4d\u6570\u5b57<\/td>\n<\/tr>\n<tr>\n<td>$nn<\/td>\n<td>\u7f16\u53f710-99 \u7684\u6355\u83b7\u7ec4&#xff0c;nn \u662f\u4e24\u4f4d\u6570\u5b57<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5404\u4e2a\u5360\u4f4d\u7b26\u89e3\u91ca<\/p>\n<li>$&amp;\n<ul>\n<li>\u4fdd\u5b58\u672c\u6b21\u5339\u914d\u5230\u7684\u5b8c\u6574\u5b57\u7b26\u4e32&#xff0c;\u7b49\u4ef7\u4e8e match[0]<\/li>\n<li>\u4f8b&#xff1a;\u628a abc \u66ff\u6362\u6210 [$&amp;] \u2192 [abc]<\/li>\n<\/ul>\n<\/li>\n<li>$&#096;&#xff08;\u7f8e\u5143\u7b26 &#043; \u53cd\u5f15\u53f7&#xff09;\n<ul>\n<li>\u5339\u914d\u5b50\u4e32\u5de6\u8fb9\u3001\u8fd8\u6ca1\u88ab\u5339\u914d\u7684\u524d\u7f00\u5185\u5bb9&#xff1b;<\/li>\n<li>\u539f\u4e32&#xff1a;123abc456&#xff0c;\u5339\u914d abc&#xff1b;<\/li>\n<li>$&#096; &#061; \u201c123\u201d<\/li>\n<\/ul>\n<\/li>\n<li>$&#039;&#xff08;\u7f8e\u5143\u7b26 &#043; \u5355\u5f15\u53f7&#xff09;\n<ul>\n<li>\u5339\u914d\u5b50\u4e32\u53f3\u8fb9\u7684\u540e\u7f00\u5185\u5bb9<\/li>\n<li>\u539f\u4e32&#xff1a;123abc456&#xff0c;\u5339\u914d abc&#xff1b;<\/li>\n<li>$\u2019 &#061; \u201c456\u201d<\/li>\n<\/ul>\n<\/li>\n<li>$n&#xff0c;n\u22080~9\n<ul>\n<li>\u53d6\u7b2c n \u4e2a\u6355\u83b7\u7ec4\u7684\u5185\u5bb9&#xff0c;\u4e00\u4f4d\u7f16\u53f7<\/li>\n<li>$1 &#061; \u7b2c\u4e00\u4e2a\u62ec\u53f7\u5206\u7ec4<\/li>\n<\/ul>\n<\/li>\n<li>$nn&#xff0c;nn\u220810~99\n<ul>\n<li>\u4e24\u4f4d\u7f16\u53f7\u6355\u83b7\u7ec4<\/li>\n<li>$10 &#061; \u8bfb\u53d6\u7b2c 10 \u53f7\u6355\u83b7\u7ec4<\/li>\n<\/ul>\n<\/li>\n<p>C&#043;&#043; \u4f7f\u7528\u6ce8\u610f\u4e8b\u9879<\/p>\n<li>POSIX(basic \/ extended\u2026)\u4e0d\u652f\u6301$&amp; $ $&#039; $1 \u8fd9\u7c7b\u66ff\u6362\u8bed\u6cd5&#xff0c;\u53ea\u6709 ECMAScript \u6a21\u5f0f\u53ef\u4ee5\u7528<\/li>\n<li>C&#043;&#043; \u666e\u901a\u53cc\u5f15\u53f7\u5b57\u7b26\u4e32&#xff0c;$ \u4e0d\u9700\u8981\u8f6c\u4e49&#xff1b;\u53cd\u659c\u6760\u624d\u9700\u8981\u8f6c\u4e49&#xff1b;<\/li>\n<li>\u5982\u679c\u5b57\u9762\u9700\u8981\u8f93\u51fa\u4e00\u4e2a\u7f8e\u5143\u7b26\u53f7 $&#xff0c;ECMAScript \u66ff\u6362\u4e32\u4f7f\u7528 $$<\/li>\n","protected":false},"excerpt":{"rendered":"<p>C\u6807\u51c6\u5e93\u539f\u751f\u652f\u6301\u591a\u79cd\u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u8303&#xff0c;\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u8bb2\u89e3\u5728\u4f7f\u7528\u6b63\u5219\u529f\u80fd\u65f6\u53ef\u4f9b\u9009\u62e9\u7684\u5404\u7c7b\u8bed\u6cd5\u4f53\u7cfb\u5dee\u5f02\u3002 \u76ee\u5f551 \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u52191.1 \u6982\u8ff01.1.1 \u6982\u8ff01.1.2 \u914d\u5957\u4fee\u9970\u6807\u8bc6&#xff08;Flag&#xff09;1.1.3 \u8865\u5145\u8bf4\u660e1.2 \u8bed\u6cd5\u5355\u5143&#xff08;Element&#xff09;1.2.1 \u6240\u6709\u6b63\u5219\u8bed\u6cd5\u901a\u7528\u57fa\u7840\u5355\u51431.2.2 ECMAScript&#xff08;C\u9ed8\u8ba4\u6b63\u5219\u8bed\u6cd5&#xff09;\u989d\u5916\u652f\u6301\u7684\u5355\u51431.2.3 awk \u8bed\u6cd5\u4e13\u5c5e\u6269\u5c55\u5355\u5143<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,3759],"topic":[],"class_list":["post-95511","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-stl"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/95511.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"C\u6807\u51c6\u5e93\u539f\u751f\u652f\u6301\u591a\u79cd\u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u8303&#xff0c;\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u8bb2\u89e3\u5728\u4f7f\u7528\u6b63\u5219\u529f\u80fd\u65f6\u53ef\u4f9b\u9009\u62e9\u7684\u5404\u7c7b\u8bed\u6cd5\u4f53\u7cfb\u5dee\u5f02\u3002 \u76ee\u5f551 \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u52191.1 \u6982\u8ff01.1.1 \u6982\u8ff01.1.2 \u914d\u5957\u4fee\u9970\u6807\u8bc6&#xff08;Flag&#xff09;1.1.3 \u8865\u5145\u8bf4\u660e1.2 \u8bed\u6cd5\u5355\u5143&#xff08;Element&#xff09;1.2.1 \u6240\u6709\u6b63\u5219\u8bed\u6cd5\u901a\u7528\u57fa\u7840\u5355\u51431.2.2 ECMAScript&#xff08;C\u9ed8\u8ba4\u6b63\u5219\u8bed\u6cd5&#xff09;\u989d\u5916\u652f\u6301\u7684\u5355\u51431.2.3 awk \u8bed\u6cd5\u4e13\u5c5e\u6269\u5c55\u5355\u5143\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/95511.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-26T05:40:26+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/95511.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/95511.html\",\"name\":\"\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-26T05:40:26+00:00\",\"dateModified\":\"2026-08-26T05:40:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/95511.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/95511.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/95511.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/95511.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"C\u6807\u51c6\u5e93\u539f\u751f\u652f\u6301\u591a\u79cd\u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u8303&#xff0c;\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u8bb2\u89e3\u5728\u4f7f\u7528\u6b63\u5219\u529f\u80fd\u65f6\u53ef\u4f9b\u9009\u62e9\u7684\u5404\u7c7b\u8bed\u6cd5\u4f53\u7cfb\u5dee\u5f02\u3002 \u76ee\u5f551 \u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u89c4\u52191.1 \u6982\u8ff01.1.1 \u6982\u8ff01.1.2 \u914d\u5957\u4fee\u9970\u6807\u8bc6&#xff08;Flag&#xff09;1.1.3 \u8865\u5145\u8bf4\u660e1.2 \u8bed\u6cd5\u5355\u5143&#xff08;Element&#xff09;1.2.1 \u6240\u6709\u6b63\u5219\u8bed\u6cd5\u901a\u7528\u57fa\u7840\u5355\u51431.2.2 ECMAScript&#xff08;C\u9ed8\u8ba4\u6b63\u5219\u8bed\u6cd5&#xff09;\u989d\u5916\u652f\u6301\u7684\u5355\u51431.2.3 awk \u8bed\u6cd5\u4e13\u5c5e\u6269\u5c55\u5355\u5143","og_url":"https:\/\/www.wsisp.com\/helps\/95511.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-26T05:40:26+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/95511.html","url":"https:\/\/www.wsisp.com\/helps\/95511.html","name":"\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-26T05:40:26+00:00","dateModified":"2026-08-26T05:40:26+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/95511.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/95511.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/95511.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010STL\u3011\u6b63\u5219\u8868\u8fbe\u5f0f\uff08C++\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/95511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=95511"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/95511\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=95511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=95511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=95511"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=95511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}