{"id":2095,"date":"2020-07-13T15:37:01","date_gmt":"2020-07-13T07:37:01","guid":{"rendered":"http:\/\/blog.coolcoding.cn\/?p=2095"},"modified":"2020-09-22T15:48:53","modified_gmt":"2020-09-22T07:48:53","slug":"notepad-%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%e6%9b%bf%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/blog.coolcoding.cn\/?p=2095","title":{"rendered":"NotePad++ \u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362"},"content":{"rendered":"\n<p>\u6ce8\u610f: \u4e0d\u652f\u6301\u591a\u884c\u8868\u8fbe\u5f0f (involving \\n, \\r, etc).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-\u57fa\u672c\u8868\u8fbe\u5f0f\">1 \u57fa\u672c\u8868\u8fbe\u5f0f<\/h2>\n\n\n\n<table class=\"wp-block-table\"><thead><tr><th>\u7b26\u53f7<\/th><th>\u89e3\u91ca<\/th><\/tr><\/thead><tbody><tr><td>.<\/td><td>\u5339\u914d\u4efb\u610f\u5b57\u7b26\uff0c\u9664\u4e86\u65b0\u4e00\u884c(\\n)\u3002\u4e5f\u5c31\u662f\u8bf4 \u201c.\u201d\u53ef\u4ee5\u5339\u914d \\r \uff0c\u5f53\u6587\u4ef6\u4e2d\u540c\u65f6\u542b\u6709\\r and \\n\u65f6\uff0c\u4f1a\u5f15\u8d77\u6df7\u4e71\u3002\u8981\u5339\u914d\u6240\u6709\u7684\u5b57\u7b26\uff0c\u4f7f\u7528\\s\\S\u3002<\/td><\/tr><tr><td>(\u2026)<\/td><td>\u8fd9\u4e2a\u5339\u914d\u4e00\u4e2a\u6807\u7b7e\u533a\u57df. \u8fd9\u4e2a\u6807\u7b7e\u53ef\u4ee5\u88ab\u8bbf\u95ee\uff0c\u901a\u8fc7\u8bed\u6cd5 \\1\u8bbf\u95ee\u7b2c\u4e00\u4e2a\u6807\u7b7e, \\2 \u8bbf\u95ee\u7b2c\u4e8c\u4e2a, \u540c\u7406 \\3 \\4 \u2026 \\9\u3002 \u8fd9\u4e9b\u6807\u7b7e\u53ef\u4ee5\u7528\u5728\u5f53\u524d\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\uff0c\u6216\u5219\u66ffsearch\u548creplace\u4e2d\u7684\u6362\u5b57\u7b26\u4e32\u3002<\/td><\/tr><tr><td>\\1, \\2, etc<\/td><td>\u5728\u66ff\u6362\u4e2d\u4ee3\u88681\u52309\u7684\u6807\u7b7e\u533a\u57df(\\1 to \\9)\u3002\u4f8b\u5982, \u67e5\u627e\u5b57\u7b26\u4e32 Fred([1-9])XXX \u5e76\u66ff\u6362\u4e3a\u5b57\u7b26\u4e32 Sam\\1YYY\u7684\u65b9\u6cd5\uff0c\u5f53\u5728\u6587\u4ef6\u4e2d\u627e\u5230Fred2XXX\u7684\u5b57\u7b26\u4e32\u65f6\uff0c\u4f1a\u66ff\u6362\u4e3aSam2YYY\u3002\u6ce8\u610f: \u53ea\u67099\u4e2a\u533a\u57df\u80fd\u4f7f\u7528\uff0c\u6240\u4ee5\u6211\u4eec\u5728\u4f7f\u7528\u65f6\u5f88\u5b89\u5168\uff0c\u50cf\\10\\2 \u8868\u793a\u533a\u57df1\u548c\u6587\u672c\u201d0\u201d\u4ee5\u53ca\u533a\u57df2\u3002<\/td><\/tr><tr><td>[\u2026]<\/td><td>\u8868\u793a\u4e00\u4e2a\u5b57\u7b26\u96c6\u5408, \u4f8b\u5982 [abc]\u8868\u793a\u4efb\u610f\u5b57\u7b26 a, b or c.\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u8303\u56f4\u4f8b\u5982[a-z] \u8868\u793a\u6240\u4ee5\u7684\u5c0f\u5199\u5b57\u6bcd\u3002<\/td><\/tr><tr><td>[^\u2026]<\/td><td>\u8868\u793a\u5b57\u7b26\u8865\u96c6. \u4f8b\u5982, [^A-Za-z] \u8868\u793a\u4efb\u610f\u5b57\u7b26\u9664\u4e86\u5b57\u6bcd\u8868\u3002<\/td><\/tr><tr><td>^<\/td><td>\u5339\u914d\u4e00\u884c\u7684\u5f00\u59cb(\u9664\u975e\u5728\u96c6\u5408\u4e2d, \u5982\u4e0b).<\/td><\/tr><tr><td>$<\/td><td>\u5339\u914d\u884c\u5c3e.<\/td><\/tr><tr><td>*<\/td><td>\u5339\u914d0\u6216\u591a\u6b21, \u4f8b\u5982 Sa*m \u5339\u914d Sm, Sam, Saam, Saaam \u7b49\u7b49.<\/td><\/tr><tr><td>+<\/td><td>\u5339\u914d1\u6b21\u6216\u591a\u6b21,\u4f8b\u5982 Sa+m \u5339\u914d Sam, Saam, Saaam \u7b49\u7b49.<\/td><\/tr><tr><td>?<\/td><td>\u5339\u914d0\u6216\u80051\u6b21, \u4f8b\u5982 Sa?m \u5339\u914d Sm, Sam.<\/td><\/tr><tr><td>{n}<\/td><td>\u5339\u914d\u786e\u5b9a\u7684 n \u6b21.\u4f8b\u5982, \u2018Sa{2}m\u2019 \u5339\u914d Saam.<\/td><\/tr><tr><td>{m,n}<\/td><td>\u5339\u914d\u81f3\u5c11m\u6b21\uff0c\u81f3\u591an\u6b21(\u5982\u679cn\u7f3a\u5931\uff0c\u5219\u4efb\u610f\u6b21\u6570).\u4f8b\u5982, \u2018Sa{2,3}m\u2019 \u5339\u914d Saam or Saaam. \u2018Sa{2,}m\u2019 \u4e0e \u2018Saa+m\u2019\u76f8\u540c<\/td><\/tr><tr><td>*?, +?, ??, {n,m}?<\/td><td>\u975e\u8d2a\u5fc3\u5339\u914d\uff0c\u5339\u914d\u7b2c\u4e00\u4e2a\u6709\u6548\u7684\u5339\u914d\uff0c\u901a\u5e38 \u2018&lt;.&gt;\u2019 \u4f1a\u5339\u914d\u6574\u4e2a \u2018content\u2019\u5b57\u7b26\u4e32 \u2013\u4f46 \u2018&lt;.?&gt;\u2019 \u53ea\u5339\u914d \u201d .\u8fd9\u4e2a\u6807\u8bb0\u4e00\u4e2a\u6807\u7b7e\u533a\u57df\uff0c\u8fd9\u4e9b\u533a\u57df\u53ef\u4ee5\u7528\u8bed\u6cd5\\1 \\2 \u7b49\u8bbf\u95ee\u591a\u4e2a\u5bf9\u5e941-9\u533a\u57df\u3002<\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-\u6807\u8bb0\u548c\u5206\u7ec4\">2 \u6807\u8bb0\u548c\u5206\u7ec4<\/h2>\n\n\n\n<table class=\"wp-block-table\"><thead><tr><th>\u7b26\u53f7<\/th><th>\u89e3\u91ca<\/th><\/tr><\/thead><tbody><tr><td>(\u2026)<\/td><td>\u4e00\u7ec4\u6355\u83b7. \u53ef\u4ee5\u901a\u8fc7\\1 \u8bbf\u95ee\u7b2c\u4e00\u4e2a\u7ec4, \\2 \u8bbf\u95ee\u7b2c\u4e8c\u4e2a.<\/td><\/tr><tr><td>(?:\u2026)<\/td><td>\u975e\u6355\u83b7\u7ec4.<\/td><\/tr><tr><td>(?=\u2026)<\/td><td>\u975e\u6355\u83b7\u7ec4 \u2013 \u5411\u524d\u65ad\u8a00. \u4f8b\u5982\u2019(.*)(?=ton)\u2019 \u8868\u8fbe\u5f0f\uff0c\u5f53 \u9047\u5230\u2019Appleton\u2019\u5b57\u7b26\u4e32\u65f6\uff0c\u4f1a\u5339\u914d\u4e3a\u2019Apple\u2019.<\/td><\/tr><tr><td>(?&lt;=\u2026)<\/td><td>\u975e\u6355\u83b7\u7ec4 \u2013 \u5411\u540e\u65ad\u8a00. \u4f8b\u5982\u2019(?&lt;=sir) (.*)\u2019 \u8868\u793a\u5f0f\uff0c\u5f53\u9047\u5230\u2019sir William\u2019 \u5b57\u7b26\u4e32\u65f6\uff0c\u5339\u914d\u4e3a\u2019 William\u2019.<\/td><\/tr><tr><td>(?!\u2026)<\/td><td>\u975e\u6355\u83b7\u7ec4 \u2013 \u6d88\u6781\u7684\u5411\u524d\u65ad\u8a00. \u4f8b\u5982\u2019.(?!e)\u2019 \u8868\u8fbe\u5f0f\uff0c\u5f53\u9047\u5230\u2019Apple\u2019\u65f6\uff0c\u4f1a\u627e\u5230\u6bcf\u4e2a\u5b57\u6bcd\u9664\u4e86 \u2018l\u2019\uff0c\u56e0\u4e3a\u5b83\u7d27\u8ddf\u7740 \u2018e\u2019.<\/td><\/tr><tr><td>(?<\/td><td>\u975e\u6355\u83b7\u7ec4 \u2013 \u6d88\u6781\u5411\u540e\u65ad\u8a00. \u4f8b\u5982 \u2018(?<\/td><\/tr><tr><td>(?P\u2026)<\/td><td>\u547d\u540d\u6240\u6355\u83b7\u7684\u7ec4. \u63d0\u4ea4\u4e00\u4e2a\u540d\u79f0\u5230\u7ec4\u4e2d\u4f9b\u540e\u7eed\u4f7f\u7528\uff0c\u4f8b\u5982\u2019(?PA[^\\s]+)\\s(?P=first)\u2019 \u4f1a\u627e\u5230 \u2018Apple Apple\u2019. \u7c7b\u4f3c\u7684 \u2018(A[^\\s]+)\\s\\1\u2019 \u4f7f\u7528\u7ec4\u540d\u800c\u4e0d\u662f\u6570\u5b57.<\/td><\/tr><tr><td>(?=name)<\/td><td>\u5339\u914d\u540d\u4e3aname\u7684\u7ec4. (?P\u2026).<\/td><\/tr><tr><td>(?#comment)<\/td><td>\u6279\u6ce8 \u2013\u62ec\u53f7\u4e2d\u7684\u5185\u5bb9\u5728\u5339\u914d\u65f6\u5c06\u88ab\u5ffd\u7565\u3002<\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-\u7279\u6b8a\u7b26\u53f7\">3 \u7279\u6b8a\u7b26\u53f7<\/h2>\n\n\n\n<table class=\"wp-block-table\"><thead><tr><th>\u7b26\u53f7<\/th><th>\u89e3\u91ca<\/th><\/tr><\/thead><tbody><tr><td>\\s<\/td><td>\u5339\u914d\u7a7a\u683c. \u6ce8\u610f\uff0c\u4f1a\u5339\u914d\u6807\u8bb0\u7684\u672b\u5c3e. \u4f7f\u7528 [[:blank:]] \u6765\u907f\u514d\u5339\u914d\u65b0\u4e00\u884c\u3002<\/td><\/tr><tr><td>\\S<\/td><td>\u5339\u914d\u975e\u7a7a\u767d<\/td><\/tr><tr><td>\\w<\/td><td>\u5339\u914d\u5355\u8bcd\u5b57\u7b26<\/td><\/tr><tr><td>\\W<\/td><td>\u5339\u914d\u975e\u5355\u8bcd\u5b57\u7b26<\/td><\/tr><tr><td>\\d<\/td><td>\u5339\u914d\u6570\u5b57\u5b57\u7b26<\/td><\/tr><tr><td>\\D<\/td><td>\u5339\u914d\u975e\u6570\u5b57\u5b57\u7b26<\/td><\/tr><tr><td>\\b<\/td><td>\u5339\u914d\u5355\u8bcd\u8fb9\u754c. \u2018\\bW\\w+\u2019 \u627e\u5230W\u5f00\u5934\u7684\u5355\u8bcd<\/td><\/tr><tr><td>\\B<\/td><td>\u5339\u914d\u975e\u5355\u8bcd\u8fb9\u754c. \u2018\\Be\\B+\u2019 \u2013 \u627e\u5230\u4f4d\u4e8e\u5355\u5b50\u4e2d\u95f4\u7684\u5b57\u6bcd\u2019e\u2019<\/td><\/tr><tr><td>\\&lt;<\/td><td>This matches the start of a word using Scintilla\u2019s definitions of words.<\/td><\/tr><tr><td>&gt;<\/td><td>This matches the end of a word using Scintilla\u2019s definition of words.<\/td><\/tr><tr><td>\\x<\/td><td>\u8fd0\u884c\u7528x\u6765\u8868\u8fbe\u53ef\u80fd\u5177\u6709\u5176\u4ed6\u610f\u601d\u7684\u5b57\u7b26\u3002\u4f8b\u5982, [ \u7528\u6765\u63d2\u5165\u5230\u6587\u672c\u4e2d\u4f5c\u4e3a[ \u800c\u4e0d\u662f\u4f5c\u4e3a\u5b57\u7b26\u96c6\u7684\u5f00\u59cb.<\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-\u5b57\u7b26\u7c7b\">4 \u5b57\u7b26\u7c7b<\/h2>\n\n\n\n<table class=\"wp-block-table\"><thead><tr><th>\u7b26\u53f7<\/th><th>\u89e3\u91ca<\/th><\/tr><\/thead><tbody><tr><td>[[:alpha:]]<\/td><td>\u5339\u914d\u5b57\u6bcd\u5b57\u7b26: [A-Za-z]<\/td><\/tr><tr><td>[[:digit:]]<\/td><td>\u5339\u914d\u6570\u5b57\u5b57\u7b26: [0-9]<\/td><\/tr><tr><td>[[:xdigit:]]<\/td><td>\u5339\u914d16\u8fdb\u5236\u5b57\u7b26: [0-9A-Fa-f]<\/td><\/tr><tr><td>[[:alnum:]]<\/td><td>\u5339\u914d\u5b57\u6bcd\u6570\u5b57\u5b57\u7b26: [0-9A-Za-z]<\/td><\/tr><tr><td>[[:lower:]]<\/td><td>\u5339\u914d\u5c0f\u5199\u5b57\u7b26: [a-z]<\/td><\/tr><tr><td>[[:upper:]]<\/td><td>\u5339\u914d\u5927\u5199\u5b57\u7b26: [A-Z]<\/td><\/tr><tr><td>[[:blank:]]<\/td><td>\u5339\u914d\u7a7a\u767d (\u7a7a\u683c or tab):[ \\t]<\/td><\/tr><tr><td>[[:space:]]<\/td><td>\u5339\u914d\u7a7a\u767d\u5b57\u7b26:[ \\t\\r\\n\\v\\f]<\/td><\/tr><tr><td>[[:punct:]]<\/td><td>\u5339\u914d\u6807\u70b9\u5b57\u7b26: [-!\u201d#$%&amp;\u2019()*+,.\/:;&lt;=&gt;?@[]_`{<\/td><\/tr><tr><td>[[:graph:]]<\/td><td>\u5339\u914d\u56fe\u5f62\u5b57\u7b26: [\\x21-\\x7E]<\/td><\/tr><tr><td>[[:print:]]<\/td><td>\u5339\u914d\u53ef\u6253\u5370\u7684\u5b57\u7b26 (graphical characters and spaces)<\/td><\/tr><tr><td>[[:cntrl:]]<\/td><td>\u5339\u914d\u63a7\u5236\u5b57\u7b26<\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5-\u66ff\u6362\u64cd\u4f5c\">5 \u66ff\u6362\u64cd\u4f5c<\/h2>\n\n\n\n<p>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u6807\u8bb0\uff0c\u901a\u8fc7\uff08\uff09\u6765\u5305\u56f4\u60f3\u8981\u7528\u7684\u5b57\u7b26\uff0c\u7136\u540e\u7528\\1 \u6765\u66ff\u6362\u5b57\u7b26\u4e32\uff0c\u7b2c\u4e00\u4e2a\u5339\u914d\u6587\u672c\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982:<\/p>\n\n\n\n<table class=\"wp-block-table\"><thead><tr><th>Text body<\/th><th>Search string<\/th><th>Replace string<\/th><th>Result<\/th><\/tr><\/thead><tbody><tr><td>Hi my name is Fred<\/td><td>my name is (.+)<\/td><td>my name is not \\1<\/td><td>Hi my name is not Fred<\/td><\/tr><tr><td>The quick brown fox jumped over the fat lazy dog<\/td><td>brown (.+) jumped over the (.+)<\/td><td>brown \\2 jumped over the \\1<\/td><td>The quick brown fat jumped over the fox lazy dog<\/td><\/tr><\/tbody><\/table>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-\u9650\u5236\">6 \u9650\u5236<\/h2>\n\n\n\n<p>Support for regular expressions in PN2 is currently limited, the supported patterns and syntax are a very small subset of the powerful expressions supported by perl. \u6700\u5927\u7684\u9650\u5236\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\u53ea\u80fd\u5339\u914d\u5355\u884c\uff0c\u4e0d\u80fd\u7528\u591a\u884c\u5339\u914d\u8868\u8fbe\u3002\u53ef\u4ee5\u7528Backslash Expressions\u4ee3\u66ff.<\/p>\n\n\n\n<p>\u51c6\u5907\u8ba1\u5212\u662f\u4f7f\u7528PCRE\u5e93 library (used elsewhere in PN2) \u6765\u652f\u6301\u6587\u6863\u641c\u7d22.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6ce8\u610f: \u4e0d\u652f\u6301\u591a\u884c\u8868\u8fbe\u5f0f (involving \\n, \\r, etc). 1 \u57fa\u672c\u8868\u8fbe\u5f0f \u7b26\u53f7 \u89e3\u91ca . \u5339 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2095"}],"collection":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2095"}],"version-history":[{"count":1,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2095\/revisions"}],"predecessor-version":[{"id":2096,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=\/wp\/v2\/posts\/2095\/revisions\/2096"}],"wp:attachment":[{"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.coolcoding.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}