{"id":653,"date":"2002-11-05T01:49:10","date_gmt":"2002-11-05T01:49:10","guid":{"rendered":"http:\/\/dev.jblove.net\/?p=653"},"modified":"2002-11-05T01:49:10","modified_gmt":"2002-11-05T01:49:10","slug":"regreplace-%eb%a1%9c-%ed%95%9c%eb%b2%88%ec%97%90-%ec%97%ac%eb%9f%ac-%ed%8c%8c%ec%9d%bc-%ec%9d%b4%eb%a6%84-%eb%b0%94%ea%be%b8%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/jblove.net\/?p=653","title":{"rendered":"reg_replace \ub85c \ud55c\ubc88\uc5d0 \uc5ec\ub7ec \ud30c\uc77c \uc774\ub984 \ubc14\uafb8\uae30"},"content":{"rendered":"<p>\uc6b0\uc218\ud55c<\/p>\n<p>\ub9e8\ub0a0 \ubcf4\uace0\ub9cc \uac00\uae30 \ubbf8\uc548\ud574\uc11c&#8230;.. \ucd08\ud5c8\uc811 \uac15\uc88c \ud558\ub098 \uc62c\ub9bd\ub2c8\ub2e4.<br \/>\n\uc911\uae09\uc790 \uc774\uc0c1\uc740 \ubcf4\uc9c0 \ub9c8\uc138\uc694.<\/p>\n<p>\uac11\uc790\uae30 \ud6c4\ubc30\uac00 \uc774\ub7f0 \ubd80\ud0c1\uc744 \ud558\ub294\uad70\uc694.<br \/>\n\uc11c\ubc84\uc5d0 html123_image345.jpg, html123_image456.gif \uc774\ub7f0 \ud30c\uc77c\uc774 \uc788\ub294\ub370<br \/>\n\uc774\uac78 html123_image346.jpg, html123_image457.jpg \ub77c\ub294 \uc774\ub984\uc73c\ub85c \ubc14\uafb8\uace0 \uc2f6\ub2e4\uad6c\uc694.<br \/>\n\uc989 \ud30c\uc77c \uc774\ub984\uc5d0 \ub4e4\uc5b4\uc788\ub294 \uc22b\uc790\ub97c \ucc3e\uc544\ub0b4\uc11c \uadf8 \uc22b\uc790\ub9cc 1\uc529 \uc99d\uac00\ub97c \uc2dc\ud0a4\uace0 \uc2f6\ub2e4\ub294 \uac81\ub2c8\ub2e4.<br \/>\n\uc790, \ud55c\ubc88 \ud574\ubcfc\uae4c\uc694.<\/p>\n<p><?<br \/>\n\/\/ \uba3c\uc800 \uac04\ub2e8\ud788 \ud658\uacbd\uc124\uc815\uc744 \uc7a1\uc544\uc90d\ub2c8\ub2e4.<\/p>\n<p>\/\/ \uc2e4\ud589\ud560 \ub514\ub809\ud1a0\ub9ac (\ubb3c\ub860 \uc4f0\uae30 \ud37c\ubbf8\uc158\uc774 \uc788\uc5b4\uc57c\uaca0\uc8e0)<br \/>\n$path = &#8220;.\/&#8221;;<\/p>\n<p>\/\/ \ud30c\uc77c\uc774\ub984\uc5d0\uc11c \uba87\ubc88\uc9f8 \ub098\uc624\ub294 \uc22b\uc790\ub97c \uc120\ud0dd\ud574 \ubc14\uafc0 \uac83\uc778\uac00<br \/>\n$what_number = 2;<\/p>\n<p>\/\/ \uadf8\ub7fc \ud574\ub2f9 \ub514\ub809\ud1a0\ub9ac\uc758 \ud30c\uc77c\uc744 \uc77d\uc5b4\uc635\ub2c8\ub2e4.<br \/>\n$files=array();<br \/>\nif (is_dir($path)) {<br \/>\n        $p = opendir($path);<br \/>\n        while($name = readdir($p)) {<br \/>\n                if (is_file(&#8220;$path\/$name&#8221;)) $files[] = $name;<br \/>\n        }<br \/>\n        closedir($p);<br \/>\n}<\/p>\n<p>\/\/\uc774\uc81c \ud30c\uc77c \uc774\ub984\uc744 \uc8fc\uc6b1 \ud6d1\uc73c\uba74\uc11c \uc774\ub984\uc744 \ubc14\uafd4\uc57c \ud558\ub294\ub370\uc694.<br \/>\n\/\/\uc7a0\uae50, \uc8fc\uc758\ud560 \uac8c \uc788\uc2b5\ub2c8\ub2e4. 456\uc744 457\ub85c \ubc14\uafb8\ub294\ub370, \uc774\ubbf8 457\uc774\ub77c\ub294 \ud30c\uc77c\uc774 \uc874\uc7ac\ud558\uba74 \uc548\ub418\uaca0\uc8e0.<br \/>\n\/\/\uadf8\ub7ec\ub2c8 \uc5ed\uc21c\uc73c\ub85c \uc791\uc5c5\uc744 \ud558\uae30\ub85c \ud569\uc2dc\ub2e4.<br \/>\nrsort($files);<\/p>\n<p>\/\/ \ud30c\uc77c\uc744 \ud558\ub098\uc529 \uc0b4\ud3b4\uc11c \uc774\ub984\uc744 \ubc14\uafc9\ub2c8\ub2e4.<br \/>\n\/\/ \uc5ec\uae30\uc11c \ud301\uc740 preg_replace \ub97c \uc0ac\uc6a9\ud560\ub54c e \ud50c\ub798\uadf8\ub97c \uc8fc\uba74<br \/>\n\/\/ PHP\ucf54\ub4dc\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e4\ub294 \uac81\ub2c8\ub2e4. <br \/>\n$cnt=$success=0;<br \/>\n$pattern = &#8220;\/(^D+&#8221;.str_repeat(&#8220;d+D+&#8221;, $what_number-1).&#8221;)(d+)\/&#8221;;<br \/>\nforeach ($files as $filename) {<br \/>\n        if (preg_match($pattern, $filename)) {<br \/>\n                $new_filename = preg_replace($pattern.&#8221;e&#8221;, &#8220;&#8216;\\1&#8217;.(intval(&#8216;\\2&#8217;)<br \/>\n+1)&#8221;, $filename, 1);<br \/>\n                echo $filename.&#8221;\uc744 &#8220;.$new_filename.&#8221;\uc73c\ub85c \ubc14\uafb8\uae30&#8230;&#8221;;<br \/>\n                if (@rename($filename, $new_filename)) {<br \/>\n                        echo &#8220;\uc131\uacf5 <BR><br \/>\n&#8220;;<br \/>\n                        $success++;<br \/>\n                } else echo &#8220;\uc2e4\ud328 <BR><br \/>\n&#8220;;<br \/>\n                $cnt++;<br \/>\n        }<br \/>\n}<\/p>\n<p>echo $cnt.&#8221;\uac1c \ud30c\uc77c \uc911\uc5d0\uc11c &#8220;.$success.&#8221;\uac1c \ud30c\uc77c\uc744 \ucc98\ub9ac\ud588\uc2b5\ub2c8\ub2e4<br \/>\n&#8220;;<\/p>\n<p>?><\/p>\n<p>\uc774\uc81c \ubcf4\uba74 \uc544\uc2dc\uaca0\uc9c0\ub9cc, \ud30c\uc77c \uc774\ub984\uc774 \uc22b\uc790\ub85c \uc2dc\uc791\ub418\ub294 \uacbd\uc6b0\uc5d0\ub294<br \/>\n\uc704\uc758 \uc774\ub984 \ubcc0\uacbd \uae30\ub2a5\uc774 \uc791\ub3d9\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \ub2e4\ub978 \ubc84\uadf8\uac00 \uc788\uc744 \uc218\ub3c4&#8230;.. &#8211;;;<br \/>\n\ud6c4\ubc30\uc758 \ud544\uc694\uc5d0 \ub530\ub77c \uae09\uc870\ud55c \uac70\uace0, \uc2e4\uc81c \uc4f0\uc77c \uc77c\uc774 \ubcc4\ub85c \uc5c6\ub294 \uc2a4\ud06c\ub9bd\ud2b8\uc785\ub2c8\ub2e4\ub9cc<br \/>\n\ud544\uc694\ud558\uc2e0 \ubd84\ub4e4\uc740 \uc880\ub354 \uc720\uc5f0\ud558\uac8c \ub9cc\ub4e4\uc5b4\uc11c \uc4f0\uc2e4 \uc218 \uc788\uaca0\uc8e0.<br \/>\n\uc774\uac74 do it yourself! \ud83d\ude42 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc6b0\uc218\ud55c \ub9e8\ub0a0 \ubcf4\uace0\ub9cc \uac00\uae30 \ubbf8\uc548\ud574\uc11c&#8230;.. \ucd08\ud5c8\uc811 \uac15\uc88c \ud558\ub098 \uc62c\ub9bd\ub2c8\ub2e4. \uc911\uae09\uc790 \uc774\uc0c1\uc740 \ubcf4\uc9c0 \ub9c8\uc138\uc694. \uac11\uc790\uae30 \ud6c4\ubc30\uac00 \uc774\ub7f0 \ubd80\ud0c1\uc744 \ud558\ub294\uad70\uc694. \uc11c\ubc84\uc5d0 html123_image345.jpg, html123_image456.gif \uc774\ub7f0 \ud30c\uc77c\uc774 \uc788\ub294\ub370 \uc774\uac78 html123_image346.jpg, html123_image457.jpg \ub77c\ub294 \uc774\ub984\uc73c\ub85c \ubc14\uafb8\uace0 \uc2f6\ub2e4\uad6c\uc694. \uc989 \ud30c\uc77c \uc774\ub984\uc5d0 \ub4e4\uc5b4\uc788\ub294 \uc22b\uc790\ub97c \ucc3e\uc544\ub0b4\uc11c \uadf8 \uc22b\uc790\ub9cc 1\uc529 \uc99d\uac00\ub97c \uc2dc\ud0a4\uace0 \uc2f6\ub2e4\ub294 \uac81\ub2c8\ub2e4. \uc790, \ud55c\ubc88 \ud574\ubcfc\uae4c\uc694. \uc774\uc81c \ubcf4\uba74 \uc544\uc2dc\uaca0\uc9c0\ub9cc, \ud30c\uc77c \uc774\ub984\uc774 \uc22b\uc790\ub85c \uc2dc\uc791\ub418\ub294 \uacbd\uc6b0\uc5d0\ub294 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[51],"tags":[],"class_list":["post-653","post","type-post","status-publish","format-standard","hentry","category-papa-php"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts\/653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=653"}],"version-history":[{"count":0,"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts\/653\/revisions"}],"wp:attachment":[{"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}