﻿{"id":783,"date":"2011-12-17T21:56:49","date_gmt":"2011-12-17T13:56:49","guid":{"rendered":"http:\/\/notes.zerobox.org\/?p=783"},"modified":"2011-12-17T21:56:49","modified_gmt":"2011-12-17T13:56:49","slug":"%e6%a8%a1%e5%bc%8f%e5%8c%b9%e9%85%8d%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"http:\/\/zerobox.org\/notes\/783.html","title":{"rendered":"\u6a21\u5f0f\u5339\u914d\u51fd\u6570"},"content":{"rendered":"<p>\u5728string\u5e93\u4e2d\u529f\u80fd\u6700\u5f3a\u5927\u7684\u51fd\u6570\u662f\uff1a<\/p>\n<p>string.find\uff08\u5b57\u7b26\u4e32\u67e5\u627e\uff09<br \/>\nstring.gsub\uff08\u5168\u5c40\u5b57\u7b26\u4e32\u66ff\u6362\uff09<br \/>\nstring.gfind\uff08\u5168\u5c40\u5b57\u7b26\u4e32\u67e5\u627e\uff09<br \/>\nstring.gmatch(\u8fd4\u56de\u67e5\u627e\u5230\u5b57\u7b26\u4e32\u7684\u8fed\u4ee3\u5668)<\/p>\n<p>\u8fd9\u4e9b\u51fd\u6570\u90fd\u662f\u57fa\u4e8e\u6a21\u5f0f\u5339\u914d\u7684\u3002\u4e0e \u5176\u4ed6\u811a\u672c\u8bed\u8a00\u4e0d\u540c\u7684\u662f\uff0cLua\u5e76\u4e0d\u4f7f\u7528POSIX\u89c4\u8303\u7684\u6b63\u5219\u8868\u8fbe\u5f0f[4]\uff08\u4e5f\u5199\u4f5cregexp\uff09\u6765\u8fdb\u884c\u6a21\u5f0f\u5339\u914d\u3002\u4e3b\u8981\u7684\u539f\u56e0\u51fa\u4e8e\u7a0b\u5e8f\u5927\u5c0f\u65b9\u9762\u7684\u8003\u8651\uff1a\u5b9e\u73b0 \u4e00\u4e2a\u5178\u578b\u7684\u7b26\u5408POSIX\u6807\u51c6\u7684regexp\u5927\u6982\u9700\u89814000\u884c\u4ee3\u7801\uff0c\u8fd9\u6bd4\u6574\u4e2aLua\u6807\u51c6\u5e93\u52a0\u5728\u4e00\u8d77\u90fd\u5927\u3002\u6743\u8861\u4e4b\u4e0b\uff0cLua\u4e2d\u7684\u6a21\u5f0f\u5339\u914d\u7684\u5b9e\u73b0\u53ea\u7528\u4e86 500\u884c\u4ee3\u7801\uff0c\u5f53\u7136\u8fd9\u610f\u5473\u7740\u4e0d\u53ef\u80fd\u5b9e\u73b0POSIX\u6240\u89c4\u8303\u7684\u6240\u6709\u66f4\u80fd\u3002\u7136\u800c\uff0cLua\u4e2d\u7684\u6a21\u5f0f\u5339\u914d\u529f\u80fd\u662f\u5f88\u5f3a\u5927\u7684\uff0c\u5e76\u4e14\u5305\u542b\u4e86\u4e00\u4e9b\u4f7f\u7528\u6807\u51c6POSIX\u6a21\u5f0f\u5339\u914d \u4e0d\u5bb9\u6613\u5b9e\u73b0\u7684\u529f\u80fd\u3002<\/p>\n<p>string.gmatch(str, pattern)<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u8fd4\u56de\u8fed\u4ee3\u5668\u7684\u51fd\u6570. \u5b9e\u9645\u7684\u7528\u4f8b\u5982\u4e0b:<\/p>\n<p>s = &#8220;hello world from Lua&#8221;<br \/>\nfor w in string.gmatch(s, &#8220;%a+&#8221;) do<br \/>\nprint(w)<br \/>\nend<\/p>\n<p>\u8fd9\u91cc\u662f\u4e00\u4e2a\u6355\u83b7\u5e76\u5c06\u914d\u5bf9\u5b57\u7b26\u5206\u522b\u5b58\u5230\u4e0d\u540c\u53d8\u91cf\u7684\u4f8b\u5b50:<\/p>\n<p>t = {}<br \/>\ns = &#8220;from=world, to=Lua&#8221;<br \/>\nfor k, v in string.gmatch(s, &#8220;(%w+)=(%w+)&#8221;) do<br \/>\nt[k]=v<br \/>\nend<br \/>\nfor k, v in pairs(t) do<br \/>\nprint(k, v)<br \/>\nend<\/p>\n<p>string.gsub(str, pattern, repl, n)<\/p>\n<p>string.gsub()\u51fd\u6570\u6839\u636e\u7ed9\u5b9a\u7684\u914d\u5bf9\u8868\u8fbe\u5f0f\u5bf9\u6e90\u5b57\u7b26\u4e32str\u8fdb\u884c\u914d\u5bf9, \u540c\u65f6\u8fd4\u56de\u6e90\u5b57\u7b26\u4e32\u7684\u4e00\u4e2a\u526f\u672c, \u8be5\u526f\u672c\u4e2d\u6210\u529f\u914d\u5bf9\u7684\u6240\u6709\u5b50\u5b57\u7b26\u4e32\u90fd\u5c06\u88ab\u66ff\u6362. \u51fd\u6570\u8fd8\u5c06\u8fd4\u56de\u6210\u529f\u914d\u5bf9\u7684\u6b21\u6570.\u5b9e\u9645\u7684\u66ff\u6362\u884c\u4e3a\u7531repl\u53c2\u6570\u7684\u7c7b\u578b\u51b3\u5b9a:<\/p>\n<p>\u5f53repl\u4e3a\u5b57\u7b26\u4e32\u65f6, \u6240\u6709\u6210\u529f\u914d\u5bf9\u7684\u5b50\u5b57\u7b26\u4e32\u5747\u4f1a\u88ab\u66ff\u6362\u6210\u6307\u5b9a\u7684repl\u5b57\u4e32.<br \/>\n\u5f53repl\u4e3atable\u65f6, \u5bf9\u6bcf\u4e2a\u6210\u529f\u914d\u5bf9\u7684\u5b50\u5b57\u7b26\u4e32, \u51fd\u6570\u5747\u4f1a\u8bd5\u56fe\u5bfb\u627e\u4ee5\u5176\u4e3akey\u503c\u7684table\u4e2d\u7684\u5143\u7d20, \u5e76\u8fd4\u56de\u8be5\u5143\u7d20. \u5982\u679c\u8be5\u914d\u5bf9\u5305\u542b\u4efb\u4f55\u6355\u83b7\u4fe1\u606f, \u5219\u4ee5\u7f16\u53f7\u4e3a1\u53f7\u7684\u6355\u83b7\u4f5c\u4e3akey\u503c\u8fdb\u884c\u67e5\u627e.<br \/>\n\u5f53repl\u4e3a\u51fd\u6570\u65f6, \u6bcf\u4e2a\u6210\u529f\u914d\u5bf9\u7684\u5b50\u5b57\u7b26\u4e32\u5747\u4f1a\u4f5c\u4e3a\u53c2\u6570\u88ab\u4f20\u5165\u5230\u8be5\u51fd\u6570\u4e2d\u53bb.<br \/>\n\u5728repl\u662ftable\u6216\u51fd\u6570\u65f6, \u5982\u679c\u8be5table\u6216\u51fd\u6570\u8fd4\u56de\u4e86\u5b57\u4e32\u6216\u6570\u5b57\u7684\u503c, \u8fd9\u4e2a\u503c\u4f9d\u7136\u4f1a\u88ab\u7528\u4e8e\u66ff\u6362\u526f\u672c\u5b57\u4e32\u4e2d\u7684\u914d\u5bf9\u5b50\u5b57\u4e32. \u5982\u679c\u8be5table\/\u51fd\u6570\u8fd4\u56de\u7684\u503c\u4e3a\u7a7a, \u5c06\u4e0d\u53d1\u751f\u66ff\u6362.<\/p>\n<p>n\u53c2\u6570\u53ef\u9009, \u5f53\u5b83\u88ab\u6307\u5b9a\u65f6, string.gsub()\u51fd\u6570\u53ea\u5bf9\u6e90\u5b57\u7b26\u4e32\u4e2d\u7684\u524dn\u4e2a\u6210\u529f\u914d\u5bf9\u7684\u6210\u5458\u8fdb\u884c\u64cd\u4f5c.<\/p>\n<p>\u4ee5\u4e0b\u662f\u51e0\u4e2a\u4f8b\u5b50:<\/p>\n<p>&gt; print(string.gsub(&#8220;hello world&#8221;, &#8220;(%w+)&#8221;, &#8220;%1 %1&#8221;))<br \/>\nhello hello world world 2<\/p>\n<p>&gt; print(string.gsub(&#8220;hello Lua&#8221;, &#8220;(%w+)%s*(%w+)&#8221;, &#8220;%2 %1&#8221;))<br \/>\nLua hello 1<\/p>\n<p>&gt; string.gsub(&#8220;hello world&#8221;, &#8220;%w+&#8221;, print)<br \/>\nhello world 2<\/p>\n<p>&gt; lookupTable = {[&#8220;hello&#8221;] = &#8220;hola&#8221;, [&#8220;world&#8221;] = &#8220;mundo&#8221;}<br \/>\n&gt; print(string.gsub(&#8220;hello world&#8221;, &#8220;(%w+)&#8221;, lookupTable))<br \/>\nhola mundo 2<br \/>\nstring.match(str, pattern, init)<\/p>\n<p>string.match()\u53ea\u5bfb\u627e\u6e90\u5b57\u4e32str\u4e2d\u7684\u7b2c\u4e00\u4e2a\u914d\u5bf9. \u53c2\u6570init\u53ef\u9009, \u6307\u5b9a\u641c\u5bfb\u8fc7\u7a0b\u7684\u8d77\u70b9, \u9ed8\u8ba4\u4e3a1.<\/p>\n<p>\u5728\u6210\u529f\u914d\u5bf9\u65f6, \u51fd\u6570\u5c06\u8fd4\u56de\u914d\u5bf9\u8868\u8fbe\u5f0f\u4e2d\u7684\u6240\u6709\u6355\u83b7\u7ed3\u679c; \u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u6355\u83b7\u6807\u8bb0, \u5219\u8fd4\u56de\u6574\u4e2a\u914d\u5bf9\u5b57\u7b26\u4e32. \u5f53\u6ca1\u6709\u6210\u529f\u7684\u914d\u5bf9\u65f6, \u8fd4\u56denil.<br \/>\nstring.match(&#8220;abcdaef&#8221;, &#8220;a&#8221;)<br \/>\n-&gt; a<\/p>\n<p>string.reverse(str)<br \/>\n\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u5012\u5e8f\u6392\u5217<br \/>\nstring.reverse(&#8220;abcde&#8221;)<br \/>\n-&gt;edcba<\/p>\n<p>string.dump(function)<br \/>\n\u8fd4\u56de\u6307\u5b9a\u51fd\u6570\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801(\u51fd\u6570\u5fc5\u987b\u662f\u4e00\u4e2aLua\u51fd\u6570\uff0c\u5e76\u4e14\u6ca1\u6709\u4e0a\u503c)<\/p>\n<p>string.find(str, pattern, init, plain)<\/p>\n<p>string.find \u7684\u57fa\u672c\u5e94\u7528\u5c31\u662f\u7528\u6765\u5728\u76ee\u6807\u4e32\uff08subject string\uff09\u5185\u641c\u7d22\u5339\u914d\u6307\u5b9a\u7684\u6a21\u5f0f\u7684\u4e32\u3002\u51fd\u6570\u5982\u679c\u627e\u5230\u5339\u914d\u7684\u4e32\u8fd4\u56de\u4ed6\u7684\u4f4d\u7f6e\uff0c\u5426\u5219\u8fd4\u56denil.\u6700\u7b80\u5355\u7684\u6a21\u5f0f\u5c31\u662f\u4e00\u4e2a\u5355\u8bcd\uff0c\u4ec5\u4ec5\u5339\u914d\u5355\u8bcd\u672c\u8eab\u3002\u6bd4\u5982\uff0c\u6a21\u5f0f &#8216;hello&#8217;\u4ec5\u4ec5\u5339\u914d\u76ee\u6807\u4e32\u4e2d\u7684&#8221;hello&#8221;\u3002\u5f53\u67e5\u627e\u5230\u6a21\u5f0f\u7684\u65f6\u5019\uff0c\u51fd\u6570\u8fd4\u56de\u4e24\u4e2a\u503c\uff1a\u5339\u914d\u4e32\u5f00\u59cb\u7d22\u5f15\u548c\u7ed3\u675f\u7d22\u5f15\u3002<br \/>\ns = &#8220;hello world&#8221;<br \/>\nstring.find(s, &#8220;hello&#8221;)\u00a0\u00a0\u00a0\u00a0&#8211;&gt; 1\u00a0\u00a0\u00a0 5<br \/>\nstring.find(s, &#8220;world&#8221;)\u00a0\u00a0\u00a0 &#8211;&gt; 7\u00a0\u00a0\u00a0 11<br \/>\nstring.find(s, &#8220;l&#8221;)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#8211;&gt; 3\u00a0\u00a0\u00a0 3<br \/>\nstring.find(s, &#8220;lll&#8221;)\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; nil<br \/>\nstring.find\u51fd\u6570\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u53ef\u9009\u7684\uff1a\u6807\u793a\u76ee\u6807\u4e32\u4e2d\u641c\u7d22\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002\u5f53\u6211\u4eec\u60f3\u67e5\u627e\u76ee\u6807\u4e32\u4e2d\u6240\u6709\u5339\u914d\u7684\u5b50\u4e32\u7684\u65f6\u5019\uff0c\u8fd9\u4e2a\u9009\u9879\u975e\u5e38\u6709\u7528\u3002\u6211\u4eec\u53ef\u4ee5\u4e0d\u65ad\u7684\u5faa\u73af\u641c\u7d22\uff0c\u6bcf\u4e00\u6b21\u4ece\u524d\u4e00\u6b21\u5339\u914d\u7684\u7ed3\u675f\u4f4d\u7f6e\u5f00\u59cb\u3002\u4e0b\u9762\u770b\u4e00\u4e2a\u4f8b\u5b50\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\u7528\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e2d\u6240\u6709\u7684\u65b0\u884c\u6784\u9020\u4e00\u4e2a\u8868\uff1a<br \/>\nlocal t = {}\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212; \u5b58\u653e\u56de\u8f66\u7b26\u7684\u4f4d\u7f6e<br \/>\nlocal i = 0<br \/>\nwhile true do<br \/>\ni = string.find(s, &#8220;\\n&#8221;, i+1)\u00a0 &#8212;\u00a0\u67e5\u627e\u4e0b\u4e00\u884c<br \/>\nif i == nil then break end<br \/>\ntable.insert(t, i)<br \/>\nend<\/p>\n<p>string.sub(str,sPos,ePos)<br \/>\nstring.gsub\u7684\u529f\u80fd\u662f\u622a\u53d6\u5b57\u7b26\u4e32\uff0c\u4ed6\u4ece\u6307\u5b9a\u8d77\u59cb\u4f4d\u7f6e\u622a\u53d6\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002string.sub\u53ef\u4ee5\u5229\u7528string.find\u8fd4\u56de\u7684\u503c\u622a\u53d6\u5339\u914d\u7684\u5b50\u4e32\u3002<br \/>\n\u5bf9\u7b80\u5355\u6a21\u5f0f\u800c\u8a00\uff0c\u5339\u914d\u7684\u5c31\u662f\u5176\u672c\u8eab<br \/>\ns = &#8220;hello world&#8221;<br \/>\nlocal i, j = string.find(s, &#8220;hello&#8221;)\u00a0\u00a0\u00a0\u00a0&#8211;&gt; 1\u00a0\u00a0\u00a0 5<br \/>\nstring.sub(s, i, j)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; hello<\/p>\n<p>string.gsub(str, sourcestr, desstr)<br \/>\nstring.gsub\u7684\u57fa\u672c\u4f5c\u7528\u662f\u7528\u6765\u67e5\u627e\u5339\u914d\u6a21\u5f0f\u7684\u4e32\uff0c\u5e76\u5c06\u4f7f\u7528\u66ff\u6362\u4e32\u5176\u66ff\u6362\u6389\uff1a<br \/>\nstring.gsub\u51fd\u6570\u6709\u4e09\u4e2a\u53c2\u6570\uff1a\u76ee\u6807\u4e32\uff0c\u6a21\u5f0f\u4e32\uff0c\u66ff\u6362\u4e32\u3002<br \/>\ns =\u00a0string.gsub(&#8220;Lua is cute&#8221;, &#8220;cute&#8221;, &#8220;great&#8221;)<br \/>\nprint(s)\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Lua is great<br \/>\ns =\u00a0string.gsub(&#8220;all lii&#8221;, &#8220;l&#8221;, &#8220;x&#8221;)<br \/>\nprint(s)\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; axx xii<br \/>\ns =\u00a0string.gsub(&#8220;Lua is great&#8221;, &#8220;perl&#8221;, &#8220;tcl&#8221;)<br \/>\nprint(s)\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; Lua is great<br \/>\n\u7b2c\u56db\u4e2a\u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u7528\u6765\u9650\u5236\u66ff\u6362\u7684\u8303\u56f4\uff1a<br \/>\ns =\u00a0string.gsub(&#8220;all lii&#8221;, &#8220;l&#8221;, &#8220;x&#8221;, 1)<br \/>\nprint(s)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; axl lii<br \/>\ns =\u00a0string.gsub(&#8220;all lii&#8221;, &#8220;l&#8221;, &#8220;x&#8221;, 2)<br \/>\nprint(s)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211;&gt; axx lii<br \/>\nstring.gsub\u7684\u7b2c\u4e8c\u4e2a\u8fd4\u56de\u503c\u8868\u793a\u4ed6\u8fdb\u884c\u66ff\u6362\u64cd\u4f5c\u7684\u6b21\u6570\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u4ee3\u7801\u6d8c\u6765\u8ba1\u7b97\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e2d\u7a7a\u683c\u51fa\u73b0\u7684\u6b21\u6570\uff1a<br \/>\n_, count =\u00a0string.gsub(str, &#8221; &#8220;, &#8221; &#8220;)<br \/>\n\uff08\u6ce8\u610f\uff0c_ \u53ea\u662f\u4e00\u4e2a\u54d1\u5143\u53d8\u91cf\uff09<\/p>\n<p>\u6a21\u5f0f<\/p>\n<p>\u4f60\u8fd8\u53ef\u4ee5\u5728\u6a21\u5f0f\u4e32\u4e2d\u4f7f\u7528\u5b57\u7b26\u7c7b\u3002\u5b57\u7b26\u7c7b\u6307\u53ef\u4ee5\u5339\u914d\u4e00\u4e2a\u7279\u5b9a\u5b57\u7b26\u96c6\u5408\u5185\u4efb\u4f55\u5b57\u7b26\u7684\u6a21\u5f0f\u9879\u3002\u6bd4\u5982\uff0c\u5b57\u7b26\u7c7b%d\u5339\u914d\u4efb\u610f\u6570\u5b57\u3002\u6240\u4ee5\u4f60\u53ef\u4ee5\u4f7f\u7528\u6a21\u5f0f\u4e32&#8217;%d%d\/%d%d\/%d%d%d%d&#8217;\u641c\u7d22dd\/mm\/yyyy\u683c\u5f0f\u7684\u65e5\u671f\uff1a<br \/>\ns = &#8220;Deadline is 30\/05\/1999, firm&#8221;<br \/>\ndate = &#8220;%d%d\/%d%d\/%d%d%d%d&#8221;<br \/>\nprint(string.sub(s, string.find(s, date)))\u00a0 \u00a0 &#8211;&gt; 30\/05\/1999<br \/>\n\u4e0b\u9762\u7684\u8868\u5217\u51fa\u4e86Lua\u652f\u6301\u7684\u6240\u6709\u5b57\u7b26\u7c7b\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p>\u5355\u4e2a\u5b57\u7b26(\u9664^$()%.[]*+-?\u5916): \u4e0e\u8be5\u5b57\u7b26\u81ea\u8eab\u914d\u5bf9<br \/>\n.(\u70b9): \u4e0e\u4efb\u4f55\u5b57\u7b26\u914d\u5bf9<br \/>\n%a: \u4e0e\u4efb\u4f55\u5b57\u6bcd\u914d\u5bf9<br \/>\n%c: \u4e0e\u4efb\u4f55\u63a7\u5236\u7b26\u914d\u5bf9(\u4f8b\u5982\\n)<br \/>\n%d: \u4e0e\u4efb\u4f55\u6570\u5b57\u914d\u5bf9<br \/>\n%l: \u4e0e\u4efb\u4f55\u5c0f\u5199\u5b57\u6bcd\u914d\u5bf9<br \/>\n%p: \u4e0e\u4efb\u4f55\u6807\u70b9(punctuation)\u914d\u5bf9<br \/>\n%s: \u4e0e\u7a7a\u767d\u5b57\u7b26\u914d\u5bf9<br \/>\n%u: \u4e0e\u4efb\u4f55\u5927\u5199\u5b57\u6bcd\u914d\u5bf9<br \/>\n%w: \u4e0e\u4efb\u4f55\u5b57\u6bcd\/\u6570\u5b57\u914d\u5bf9<br \/>\n%x: \u4e0e\u4efb\u4f55\u5341\u516d\u8fdb\u5236\u6570\u914d\u5bf9<br \/>\n%z: \u4e0e\u4efb\u4f55\u4ee3\u88680\u7684\u5b57\u7b26\u914d\u5bf9<br \/>\n%x(\u6b64\u5904x\u662f\u975e\u5b57\u6bcd\u975e\u6570\u5b57\u5b57\u7b26): \u4e0e\u5b57\u7b26x\u914d\u5bf9. \u4e3b\u8981\u7528\u6765\u5904\u7406\u8868\u8fbe\u5f0f\u4e2d\u6709\u529f\u80fd\u7684\u5b57\u7b26(^$()%.[]*+-?)\u7684\u914d\u5bf9\u95ee\u9898, \u4f8b\u5982%%\u4e0e%\u914d\u5bf9<br \/>\n[\u6570\u4e2a\u5b57\u7b26\u7c7b]:\u00a0\u4e0e\u4efb\u4f55[]\u4e2d\u5305\u542b\u7684\u5b57\u7b26\u7c7b\u914d\u5bf9. \u4f8b\u5982[%w_]\u4e0e\u4efb\u4f55\u5b57\u6bcd\/\u6570\u5b57, \u6216\u4e0b\u5212\u7ebf\u7b26\u53f7(_)\u914d\u5bf9<br \/>\n[^\u6570\u4e2a\u5b57\u7b26\u7c7b]: \u4e0e\u4efb\u4f55\u4e0d\u5305\u542b\u5728[]\u4e2d\u7684\u5b57\u7b26\u7c7b\u914d\u5bf9. \u4f8b\u5982[^%s]\u4e0e\u4efb\u4f55\u975e\u7a7a\u767d\u5b57\u7b26\u914d\u5bf9<\/p>\n<p>\u5f53\u4e0a\u8ff0\u7684\u5b57\u7b26\u7c7b\u7528\u5927\u5199\u4e66\u5199\u65f6, \u8868\u793a\u4e0e\u975e\u6b64\u5b57\u7b26\u7c7b\u7684\u4efb\u4f55\u5b57\u7b26\u914d\u5bf9. \u4f8b\u5982, %S\u8868\u793a\u4e0e\u4efb\u4f55\u975e\u7a7a\u767d\u5b57\u7b26\u914d\u5bf9.\u4f8b\u5982\uff0c&#8217;%A&#8217;\u975e\u5b57\u6bcd\u7684\u5b57\u7b26<br \/>\nprint(string.gsub(&#8220;hello, up-down!&#8221;, &#8220;%A&#8221;, &#8220;.&#8221;))<br \/>\n&#8211;&gt; hello..up.down. 4<br \/>\n\uff08\u6570\u5b574\u4e0d\u662f\u5b57\u7b26\u4e32\u7ed3\u679c\u7684\u4e00\u90e8\u5206\uff0c\u4ed6\u662fgsub\u8fd4\u56de\u7684\u7b2c\u4e8c\u4e2a\u7ed3\u679c\uff0c\u4ee3\u8868\u53d1\u751f\u66ff\u6362\u7684\u6b21\u6570\u3002\u4e0b\u9762\u5176\u4ed6\u7684\u5173\u4e8e\u6253\u5370gsub\u7ed3\u679c\u7684\u4f8b\u5b50\u4e2d\u5c06\u4f1a\u5ffd\u7565\u8fd9\u4e2a\u6570\u503c\u3002\uff09\u5728\u6a21\u5f0f\u5339\u914d\u4e2d\u6709\u4e00\u4e9b\u7279\u6b8a\u5b57\u7b26\uff0c\u4ed6\u4eec\u6709\u7279\u6b8a\u7684\u610f\u4e49\uff0cLua\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u5982\u4e0b\uff1a<br \/>\n( ) . % + &#8211; * ? [ ^ $<br \/>\n&#8216;%&#8217; \u7528\u4f5c\u7279\u6b8a\u5b57\u7b26\u7684\u8f6c\u4e49\u5b57\u7b26\uff0c\u56e0\u6b64 &#8216;%.&#8217; \u5339\u914d\u70b9\uff1b&#8217;%%&#8217; \u5339\u914d\u5b57\u7b26 &#8216;%&#8217;\u3002\u8f6c\u4e49\u5b57\u7b26 &#8216;%&#8217;\u4e0d\u4ec5\u53ef\u4ee5\u7528\u6765\u8f6c\u4e49\u7279\u6b8a\u5b57\u7b26\uff0c\u8fd8\u53ef\u4ee5\u7528\u4e8e\u6240\u6709\u7684\u975e\u5b57\u6bcd\u7684\u5b57\u7b26\u3002\u5f53\u5bf9\u4e00\u4e2a\u5b57\u7b26\u6709\u7591\u95ee\u7684\u65f6\u5019\uff0c\u4e3a\u5b89\u5168\u8d77\u89c1\u8bf7\u4f7f\u7528\u8f6c\u4e49\u5b57\u7b26\u8f6c\u4e49\u4ed6\u3002<br \/>\n\u5bf9 Lua\u800c\u8a00\uff0c\u6a21\u5f0f\u4e32\u5c31\u662f\u666e\u901a\u7684\u5b57\u7b26\u4e32\u3002\u4ed6\u4eec\u548c\u5176\u4ed6\u7684\u5b57\u7b26\u4e32\u6ca1\u6709\u533a\u522b\uff0c\u4e5f\u4e0d\u4f1a\u53d7\u5230\u7279\u6b8a\u5bf9\u5f85\u3002\u53ea\u6709\u4ed6\u4eec\u88ab\u7528\u4f5c\u6a21\u5f0f\u4e32\u7528\u4e8e\u51fd\u6570\u7684\u65f6\u5019\uff0c&#8217;%&#8217; \u624d\u4f5c\u4e3a\u8f6c\u4e49\u5b57\u7b26\u3002\u6240\u4ee5\uff0c\u5982\u679c\u4f60\u9700\u8981\u5728\u4e00\u4e2a\u6a21\u5f0f\u4e32\u5185\u653e\u7f6e\u5f15\u53f7\u7684\u8bdd\uff0c\u4f60\u5fc5\u987b\u4f7f\u7528\u5728\u5176\u4ed6\u7684\u5b57\u7b26\u4e32\u4e2d\u653e\u7f6e\u5f15\u53f7\u7684\u65b9\u6cd5\u6765\u5904\u7406\uff0c\u4f7f\u7528 &#8216;\\&#8217; \u8f6c\u4e49\u5f15\u53f7\uff0c&#8217;\\&#8217; \u662fLua\u7684\u8f6c\u4e49\u7b26\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u65b9\u62ec\u53f7\u5c06\u5b57\u7b26\u7c7b\u6216\u8005\u5b57\u7b26\u62ec\u8d77\u6765\u521b\u5efa\u81ea\u5df1\u7684\u5b57\u7b26\u7c7b\uff08\u8bd1\u8005\uff1aLua\u79f0\u4e4b\u4e3achar-set\uff0c\u5c31\u662f\u6307\u4f20\u7edf\u6b63\u5219\u8868\u8fbe\u5f0f\u6982\u5ff5\u4e2d\u7684\u62ec\u53f7\u8868 \u8fbe\u5f0f\uff09\u3002\u6bd4\u5982\uff0c'[%w_]&#8217; \u5c06\u5339\u914d\u5b57\u6bcd\u6570\u5b57\u548c\u4e0b\u5212\u7ebf\uff0c'[01]&#8217; \u5339\u914d\u4e8c\u8fdb\u5236\u6570\u5b57\uff0c'[%[%]]&#8217; \u5339\u914d\u4e00\u5bf9\u65b9\u62ec\u53f7\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u7edf\u8ba1\u6587\u672c\u4e2d\u5143\u97f3\u5b57\u6bcd\u51fa\u73b0\u7684\u6b21\u6570\uff1a<\/p>\n<p>_, nvow = string.gsub(text, &#8220;[AEIOUaeiou]&#8221;, &#8220;&#8221;)<\/p>\n<p>\u5728 char-set\u4e2d\u53ef\u4ee5\u4f7f\u7528\u8303\u56f4\u8868\u793a\u5b57\u7b26\u7684\u96c6\u5408\uff0c\u7b2c\u4e00\u4e2a\u5b57\u7b26\u548c\u6700\u540e\u4e00\u4e2a\u5b57\u7b26\u4e4b\u95f4\u7528\u8fde\u5b57\u7b26\u8fde\u63a5\u8868\u793a\u8fd9\u4e24\u4e2a\u5b57\u7b26\u4e4b\u95f4\u8303\u56f4\u5185\u7684\u5b57\u7b26\u96c6\u5408\u3002\u5927\u90e8\u5206\u7684\u5e38\u7528\u5b57\u7b26\u8303\u56f4\u90fd \u5df2\u7ecf\u9884\u5b9a\u4e49\u597d\u4e86\uff0c\u6240\u4ee5\u4e00\u822c\u4f60\u4e0d\u9700\u8981\u81ea\u5df1\u5b9a\u4e49\u5b57\u7b26\u7684\u96c6\u5408\u3002\u6bd4\u5982\uff0c&#8217;%d&#8217; \u8868\u793a &#8216;[0-9]&#8217;\uff1b&#8217;%x&#8217; \u8868\u793a &#8216;[0-9a-fA-F]&#8217;\u3002\u7136\u800c\uff0c\u5982\u679c\u4f60\u60f3\u67e5\u627e\u516b\u8fdb\u5236\u6570\uff0c\u4f60\u53ef\u80fd\u66f4\u559c\u6b22\u4f7f\u7528 &#8216;[0-7]&#8217; \u800c\u4e0d\u662f &#8216;[01234567]&#8217;\u3002\u4f60\u53ef\u4ee5\u5728\u5b57\u7b26\u96c6(char-set)\u7684\u5f00\u59cb\u5904\u4f7f\u7528 &#8216;^&#8217; \u8868\u793a\u5176\u8865\u96c6\uff1a'[^0-7]&#8217; \u5339\u914d\u4efb\u4f55\u4e0d\u662f\u516b\u8fdb\u5236\u6570\u5b57\u7684\u5b57\u7b26\uff1b'[^\\n]&#8217; \u5339\u914d\u4efb\u4f55\u975e\u6362\u884c\u7b26\u6237\u7684\u5b57\u7b26\u3002\u8bb0\u4f4f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5927\u5199\u7684\u5b57\u7b26\u7c7b\u8868\u793a\u5176\u8865\u96c6\uff1a&#8217;%S&#8217; \u6bd4 &#8216;[^%s]&#8217; \u8981\u7b80\u77ed\u4e9b\u3002<br \/>\nLua\u7684\u5b57\u7b26\u7c7b\u4f9d\u8d56\u4e8e\u672c\u5730\u73af\u5883\uff0c\u6240\u4ee5 &#8216;[a-z]&#8217; \u53ef\u80fd\u4e0e &#8216;%l&#8217; \u8868\u793a\u7684\u5b57\u7b26\u96c6\u4e0d\u540c\u3002\u5728\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u540e\u8005\u5305\u62ec &#8216;\u00e7&#8217; \u548c &#8216;\u00e3&#8217;\uff0c\u800c\u524d\u8005\u6ca1\u6709\u3002\u5e94\u8be5\u5c3d\u53ef\u80fd\u7684\u4f7f\u7528\u540e\u8005\u6765\u8868\u793a\u5b57\u6bcd\uff0c\u9664\u975e\u51fa\u4e8e\u67d0\u4e9b\u7279\u6b8a\u8003\u8651\uff0c\u56e0\u4e3a\u540e\u8005\u66f4\u7b80\u5355\u3001\u65b9\u4fbf\u3001\u66f4\u9ad8\u6548\u3002<br \/>\n\u53ef\u4ee5\u4f7f\u7528\u4fee\u9970\u7b26\u6765\u4fee\u9970\u6a21\u5f0f\u589e\u5f3a\u6a21\u5f0f\u7684\u8868\u8fbe\u80fd\u529b\uff0cLua\u4e2d\u7684\u6a21\u5f0f\u4fee\u9970\u7b26\u6709\u56db\u4e2a\uff1a<\/p>\n<p>+\u00a0 \u00a0 \u00a0 \u5339\u914d\u524d\u4e00\u5b57\u7b261\u6b21\u6216\u591a\u6b21<br \/>\n*\u00a0 \u00a0 \u00a0 \u5339\u914d\u524d\u4e00\u5b57\u7b260\u6b21\u6216\u591a\u6b21<br \/>\n&#8211;\u00a0 \u00a0 \u00a0 \u5339\u914d\u524d\u4e00\u5b57\u7b260\u6b21\u6216\u591a\u6b21<br \/>\n?\u00a0 \u00a0 \u00a0 \u5339\u914d\u524d\u4e00\u5b57\u7b260\u6b21\u62161\u6b21<\/p>\n<p>&#8216;+&#8217;\uff0c\u5339\u914d\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\uff0c\u603b\u662f\u8fdb\u884c\u6700\u957f\u7684\u5339\u914d\u3002\u6bd4\u5982\uff0c\u6a21\u5f0f\u4e32 &#8216;%a+&#8217; \u5339\u914d\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u6bcd\u6216\u8005\u4e00\u4e2a\u5355\u8bcd\uff1a<\/p>\n<p>print(string.gsub(&#8220;one, and two; and three&#8221;, &#8220;%a+&#8221;, &#8220;word&#8221;))<br \/>\n&#8211;&gt; word, word word; word word<\/p>\n<p>&#8216;%d+&#8217; \u5339\u914d\u4e00\u4e2a\u6216\u591a\u4e2a\u6570\u5b57\uff08\u6574\u6570\uff09\uff1a<\/p>\n<p>i, j = string.find(&#8220;the number 1298 is even&#8221;, &#8220;%d+&#8221;)<br \/>\nprint(i,j)\u00a0 \u00a0 &#8211;&gt; 12\u00a0 15<\/p>\n<p>&#8216;*&#8217; \u4e0e &#8216;+&#8217; \u7c7b\u4f3c\uff0c\u4f46\u662f\u4ed6\u5339\u914d\u4e00\u4e2a\u5b57\u7b260\u6b21\u6216\u591a\u6b21\u51fa\u73b0. \u4e00\u4e2a\u5178\u578b\u7684\u5e94\u7528\u662f\u5339\u914d\u7a7a\u767d\u3002\u6bd4\u5982\uff0c\u4e3a\u4e86\u5339\u914d\u4e00\u5bf9\u5706\u62ec\u53f7()\u6216\u8005\u62ec\u53f7\u4e4b\u95f4\u7684\u7a7a\u767d\uff0c\u53ef\u4ee5\u4f7f\u7528 &#8216;%(%s*%)&#8217;\u3002\uff08 &#8216;%s*&#8217; \u7528\u6765\u5339\u914d0\u4e2a\u6216\u591a\u4e2a\u7a7a\u767d\u3002\u7531\u4e8e\u5706\u62ec\u53f7\u5728\u6a21\u5f0f\u4e2d\u6709\u7279\u6b8a\u7684\u542b\u4e49\uff0c\u6240\u4ee5\u6211\u4eec\u5fc5\u987b\u4f7f\u7528 &#8216;%&#8217; \u8f6c\u4e49\u4ed6\u3002\uff09\u518d\u770b\u4e00\u4e2a\u4f8b\u5b50\uff0c'[_%a][_%w]*&#8217; \u5339\u914dLua\u7a0b\u5e8f\u4e2d\u7684\u6807\u793a\u7b26\uff1a\u5b57\u6bcd\u6216\u8005\u4e0b\u5212\u7ebf\u5f00\u5934\u7684\u5b57\u6bcd\u4e0b\u5212\u7ebf\u6570\u5b57\u5e8f\u5217\u3002<br \/>\n&#8216;-&#8216; \u4e0e &#8216;*&#8217; \u4e00\u6837\uff0c\u90fd\u5339\u914d\u4e00\u4e2a\u5b57\u7b26\u76840\u6b21\u6216\u591a\u6b21\u51fa\u73b0\uff0c\u4f46\u662f\u4ed6\u8fdb\u884c\u7684\u662f\u6700\u77ed\u5339\u914d\u3002\u67d0\u4e9b\u65f6\u5019\u8fd9\u4e24\u4e2a\u7528\u8d77\u6765\u6ca1\u6709\u533a\u522b\uff0c\u4f46\u6709\u4e9b\u65f6\u5019\u7ed3\u679c\u5c06\u622a\u7136\u4e0d\u540c\u3002\u6bd4\u5982\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u6a21\u5f0f &#8216;[_%a][_%w]-&#8216; \u6765\u67e5\u627e\u6807\u793a\u7b26\uff0c\u4f60\u5c06\u53ea\u80fd\u627e\u5230\u7b2c\u4e00\u4e2a\u5b57\u6bcd\uff0c\u56e0\u4e3a &#8216;[_%w]-&#8216; \u6c38\u8fdc\u5339\u914d\u7a7a\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u5047\u5b9a\u4f60\u60f3\u67e5\u627eC\u7a0b\u5e8f\u4e2d\u7684\u6ce8\u91ca\uff0c\u5f88\u591a\u4eba\u53ef\u80fd\u4f7f\u7528 &#8216;\/%*.*%*\/&#8217;\uff08\u4e5f\u5c31\u662f\u8bf4 &#8220;\/*&#8221; \u540e\u9762\u8ddf\u7740\u4efb\u610f\u591a\u4e2a\u5b57\u7b26\uff0c\u7136\u540e\u8ddf\u7740 &#8220;*\/&#8221; \uff09\u3002\u7136\u800c\uff0c\u7531\u4e8e &#8216;.*&#8217; \u8fdb\u884c\u7684\u662f\u6700\u957f\u5339\u914d\uff0c\u8fd9\u4e2a\u6a21\u5f0f\u5c06\u5339\u914d\u7a0b\u5e8f\u4e2d\u7b2c\u4e00\u4e2a &#8220;\/*&#8221; \u548c\u6700\u540e\u4e00\u4e2a &#8220;*\/&#8221; \u4e4b\u95f4\u6240\u6709\u90e8\u5206\uff1a<\/p>\n<p>test = &#8220;int x; \/* x *\/ int y; \/* y *\/&#8221;<br \/>\nprint(string.gsub(test, &#8220;\/%*.*%*\/&#8221;, &#8220;&lt;COMMENT&gt;&#8221;))<br \/>\n&#8211;&gt; int x; &lt;COMMENT&gt;<\/p>\n<p>\u7136\u800c\u6a21\u5f0f &#8216;.-&#8216; \u8fdb\u884c\u7684\u662f\u6700\u77ed\u5339\u914d\uff0c\u5979\u4f1a\u5339\u914d &#8220;\/*&#8221; \u5f00\u59cb\u5230\u7b2c\u4e00\u4e2a &#8220;*\/&#8221; \u4e4b\u524d\u7684\u90e8\u5206\uff1a<\/p>\n<p>test = &#8220;int x; \/* x *\/ int y; \/* y *\/&#8221;<br \/>\nprint(string.gsub(test, &#8220;\/%*.-%*\/&#8221;, &#8220;&lt;COMMENT&gt;&#8221;))<br \/>\n&#8211;&gt; int x; &lt;COMMENT&gt; int y; &lt;COMMENT&gt;<\/p>\n<p>&#8216;?&#8217; \u5339\u914d\u4e00\u4e2a\u5b57\u7b260\u6b21\u62161\u6b21\u3002 \u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5047\u5b9a\u6211\u4eec\u60f3\u5728\u4e00\u6bb5\u6587\u672c\u5185\u67e5\u627e\u4e00\u4e2a\u6574\u6570\uff0c\u6574\u6570\u53ef\u80fd\u5e26\u6709\u6b63\u8d1f\u53f7\u3002\u6a21\u5f0f &#8216;[+-]?%d+&#8217; \u7b26\u5408\u6211\u4eec\u7684\u8981\u6c42\uff0c\u5b83\u53ef\u4ee5\u5339\u914d\u50cf &#8220;-12&#8243;\u3001&#8221;23&#8221; \u548c &#8220;+1009&#8221; \u7b49\u6570\u5b57\u3002'[+-]&#8217; \u662f\u4e00\u4e2a\u5339\u914d &#8216;+&#8217; \u6216\u8005 &#8216;-&#8216; \u7684\u5b57\u7b26\u7c7b\uff1b\u63a5\u4e0b\u6765\u7684 &#8216;?&#8217; \u610f\u601d\u662f\u5339\u914d\u524d\u9762\u7684\u5b57\u7b26\u7c7b0\u6b21\u6216\u80051\u6b21\u3002<br \/>\n\u4e0e\u5176\u4ed6\u7cfb\u7edf\u7684\u6a21\u5f0f\u4e0d\u540c\u7684\u662f\uff0cLua\u4e2d\u7684\u4fee\u9970\u7b26\u4e0d\u80fd\u7528\u5b57\u7b26\u7c7b\uff1b\u4e0d\u80fd\u5c06\u6a21\u5f0f\u5206\u7ec4\u7136\u540e\u4f7f\u7528\u4fee\u9970\u7b26\u4f5c\u7528\u8fd9\u4e2a\u5206\u7ec4\u3002\u6bd4\u5982\uff0c\u6ca1\u6709\u4e00\u4e2a\u6a21\u5f0f\u53ef\u4ee5\u5339\u914d\u4e00\u4e2a\u53ef\u9009\u7684\u5355\u8bcd\uff08\u9664\u975e\u8fd9\u4e2a\u5355\u8bcd\u53ea\u6709\u4e00\u4e2a\u5b57\u6bcd\uff09\u3002\u4e0b\u9762\u6211\u5c06\u770b\u5230\uff0c\u901a\u5e38\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u9ad8\u7ea7\u6280\u672f\u7ed5\u5f00\u8fd9\u4e2a\u9650\u5236\u3002<br \/>\n\u4ee5 &#8216;^&#8217; \u5f00\u5934\u7684\u6a21\u5f0f\u53ea\u5339\u914d\u76ee\u6807\u4e32\u7684\u5f00\u59cb\u90e8\u5206\uff0c\u76f8\u4f3c\u7684\uff0c\u4ee5 &#8216;$&#8217; \u7ed3\u5c3e\u7684\u6a21\u5f0f\u53ea\u5339\u914d\u76ee\u6807\u4e32\u7684\u7ed3\u5c3e\u90e8\u5206\u3002\u8fd9\u4e0d\u4ec5\u53ef\u4ee5\u7528\u6765\u9650\u5236\u4f60\u8981\u67e5\u627e\u7684\u6a21\u5f0f\uff0c\u8fd8\u53ef\u4ee5\u5b9a\u4f4d\uff08anchor\uff09\u6a21\u5f0f\u3002\u6bd4\u5982\uff1a<\/p>\n<p>if string.find(s, &#8220;^%d&#8221;) then &#8230;<\/p>\n<p>\u68c0\u67e5\u5b57\u7b26\u4e32s\u662f\u5426\u4ee5\u6570\u5b57\u5f00\u5934\uff0c\u800c<\/p>\n<p>if string.find(s, &#8220;^[+-]?%d+$&#8221;) then &#8230;<\/p>\n<p>\u68c0\u67e5\u5b57\u7b26\u4e32s\u662f\u5426\u662f\u4e00\u4e2a\u6574\u6570\u3002<br \/>\n&#8216;%b&#8217; \u7528\u6765\u5339\u914d\u5bf9\u79f0\u7684\u5b57\u7b26\u3002\u5e38\u5199\u4e3a &#8216;%bxy&#8217; \uff0cx\u548cy\u662f\u4efb\u610f\u4e24\u4e2a\u4e0d\u540c\u7684\u5b57\u7b26\uff1bx\u4f5c\u4e3a\u5339\u914d\u7684\u5f00\u59cb\uff0cy\u4f5c\u4e3a\u5339\u914d\u7684\u7ed3\u675f\u3002\u6bd4\u5982\uff0c&#8217;%b()&#8217; \u5339\u914d\u4ee5 &#8216;(&#8216; \u5f00\u59cb\uff0c\u4ee5 &#8216;)&#8217; \u7ed3\u675f\u7684\u5b57\u7b26\u4e32\uff1a<\/p>\n<p>print(string.gsub(&#8220;a (enclosed (in) parentheses) line&#8221;, &#8220;%b()&#8221;, &#8220;&#8221;))<br \/>\n&#8211;&gt; a line<\/p>\n<p>\u5e38\u7528\u7684\u8fd9\u79cd\u6a21\u5f0f\u6709\uff1a&#8217;%b()&#8217; \uff0c&#8217;%b[]&#8217;\uff0c&#8217;%b%{%}&#8217; \u548c &#8216;%b&lt;&gt;&#8217;\u3002\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u5b57\u7b26\u4f5c\u4e3a\u5206\u9694\u7b26\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728string\u5e93\u4e2d\u529f\u80fd\u6700\u5f3a\u5927\u7684\u51fd\u6570\u662f\uff1a string.find\uff08\u5b57\u7b26\u4e32\u67e5\u627e\uff09 s &hellip;<\/p>\n<p class=\"read-more\"><a href=\"http:\/\/zerobox.org\/notes\/783.html\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[183],"class_list":["post-783","post","type-post","status-publish","format-standard","hentry","tag-183"],"views":1021,"_links":{"self":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/comments?post=783"}],"version-history":[{"count":0,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/posts\/783\/revisions"}],"wp:attachment":[{"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/media?parent=783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/categories?post=783"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zerobox.org\/notes\/wp-json\/wp\/v2\/tags?post=783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}