{"id":1770,"date":"2015-05-07T17:56:48","date_gmt":"2015-05-07T08:56:48","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=1770"},"modified":"2015-05-08T11:13:18","modified_gmt":"2015-05-08T02:13:18","slug":"charactertrim","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/charactertrim\/","title":{"rendered":"\u6587\u5b57\u5217\uff1a\u6587\u5b57\u5217\u306e\u7a7a\u767d\u3092\u524a\u9664\uff08Trim \u95a2\u6570, LTrim\u95a2\u6570, RTrim\u95a2\u6570\uff09"},"content":{"rendered":"<h2>Trim \u95a2\u6570\u30fbLTrim \u95a2\u6570\u30fbRTrim \u95a2\u6570\u306e\u4f7f\u3044\u65b9<\/h2>\n<br \/>\n<div class=\"m30-l\">\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p><span class=\"red\">\uff1c\u5148\u982d\u3068\u672b\u5c3e\u306e\u7a7a\u767d\u3092\u524a\u9664<\/span><br \/>\n<em>result<\/em> = <strong>Trim<\/strong> ( <em>string<\/em> )<\/p>\n<p><span class=\"red\">\uff1c\u5148\u982d\u306e\u7a7a\u767d\u3092\u524a\u9664<\/span><br \/>\n<em>result_l<\/em> = <strong>LTrim<\/strong> ( <em>string<\/em> )<\/p>\n<p><span class=\"red\">\uff1c\u672b\u5c3e\u306e\u7a7a\u767d\u3092\u524a\u9664<\/span><br \/>\n<em>result_r<\/em> = <strong>RTrim<\/strong> ( <em>string<\/em> )<\/p>\n<\/div>\n<br \/>\n<h3>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h3>\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>string&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u4efb\u610f\u306e\u6587\u5b57\u5217\u30fb\u6587\u5b57\u5217\u5f0f\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>result&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>string<\/em> \u306e\u5148\u982d\u307e\u305f\u306f\u672b\u5c3e\u306b\u3042\u308b\u7a7a\u767d\u6587\u5b57\uff08\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u30fb\u5168\u89d2\u30b9\u30da\u30fc\u30b9\uff09\u5168\u3066\u3092\u524a\u9664\u3057\u305f\u7d50\u679c\uff08\u6587\u5b57\u5217\u578b\uff1aString\uff09\u3002<\/li>\n<li>result_l&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>string<\/em> \u306e\u5148\u982d\u306b\u3042\u308b\u7a7a\u767d\u6587\u5b57\uff08\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u30fb\u5168\u89d2\u30b9\u30da\u30fc\u30b9\uff09\u5168\u3066\u3092\u524a\u9664\u3057\u305f\u7d50\u679c\uff08\u6587\u5b57\u5217\u578b\uff1aString\uff09\u3002<\/li>\n<li>result_u&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5f15\u6570 <em>string<\/em> \u306e\u672b\u5c3e\u306b\u3042\u308b\u7a7a\u767d\u6587\u5b57\uff08\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u30fb\u5168\u89d2\u30b9\u30da\u30fc\u30b9\uff09\u5168\u3066\u3092\u524a\u9664\u3057\u305f\u7d50\u679c\uff08\u6587\u5b57\u5217\u578b\uff1aString\uff09\u3002<\/li>\n<\/ul>\n<br \/>\n<p class=\"caution4\">\u5f15\u6570 <em>string<\/em> \u304c\u3001<strong>Null \u5024<\/strong> \u3092\u542b\u3080\u5834\u5408\u306f\u3001<strong>Null \u5024<\/strong> \u3092\u8fd4\u3057\u307e\u3059<\/p>\n<p class=\"caution4\"><strong>Trim,LTrim,RTrim \u95a2\u6570<\/strong>\u306f\u3001\u300c\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u300d\u306e\u307f\u524a\u9664\u3001\u300c\u5168\u89d2\u30b9\u30da\u30fc\u30b9\u300d\u306e\u307f\u524a\u9664\u3001\u307e\u305f\u6587\u5b57\u5217\u5185\u306e\u300c\u30b9\u30da\u30fc\u30b9\u300d\u3092\u524a\u9664\u3068\u3044\u3063\u305f\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u3001<span class=\"red\"><strong><a href=\"https:\/\/excelwork.info\/excel\/characterreplace\/\">Replace \u95a2\u6570<\/a><\/strong><\/span>\uff08\u6587\u5b57\u306e\u7f6e\u304d\u63db\u3048\uff09\u3092\u4f7f\u7528\u3059\u308b\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<br \/>\n  \u3000\uff08\u4f8b\uff09<em>newStr<\/em> = <strong>Replace<\/strong> ( <em>string<\/em>, &#8221; &#8220;, &#8220;&#8221; )<br \/>\n  \u3000 \u203b \u6587\u5b57\u5217 <em>string<\/em> \u304b\u3089\u300c\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u300d\u3092\u5168\u3066\u524a\u9664\u3057\u305f\u7d50\u679c\u3092 <em>newStr<\/em> \u306b\u4ee3\u5165\n<\/p>\n<\/div>\n<br \/><br \/>\n<h2>Trim \u95a2\u6570\u30fbLTrim \u95a2\u6570\u30fbRTrim \u95a2\u6570 \u306e\u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"Trim \u95a2\u6570\u30fbLTrim \u95a2\u6570\u30fbRTrim \u95a2\u6570\u306e\u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\n\r\nSub Sample_Trim02()\r\n\r\n    Dim myStr As String, newStr As String\r\n    \r\n    myStr = \"\u3000\u3053\u3093\u306b\u3061\u306f&gt;\u3000&lt;abc \"      '\u6587\u5b57\u5217\u5148\u982d\u306b\u300c\u5168\u89d2\u30b9\u30da\u30fc\u30b9\u300d\u300c&gt;\u300d\u3068\u300c&lt;\u300d\u306e\u9593\u306b\u300c\u5168\u89d2\u30b9\u30da\u30fc\u30b9\u300d\u672b\u5c3e\u306b\u300c\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u300d\r\n    Debug.Print myStr\r\n    Debug.Print Len(myStr)              '\u6587\u5b57\u6570\u306e\u78ba\u8a8d\uff0813\uff09\r\n\r\n    newStr = LTrim(myStr)               '\u5148\u982d\u306e\u7a7a\u767d\u6587\u5b57\u3092\u524a\u9664\r\n    Debug.Print newStr\r\n    Debug.Print Len(newStr)             '\u6587\u5b57\u6570\u306e\u78ba\u8a8d\uff0812\uff09\r\n\r\n    newStr = RTrim(myStr)               '\u672b\u5c3e\u306e\u7a7a\u767d\u6587\u5b57\u3092\u524a\u9664\r\n    Debug.Print newStr\r\n    Debug.Print Len(newStr)             '\u6587\u5b57\u6570\u306e\u78ba\u8a8d\uff0812\uff09\r\n\r\n    newStr = Trim(myStr)                '\u5148\u982d\u672b\u5c3e\u306e\u7a7a\u767d\u6587\u5b57\u3092\u524a\u9664\r\n    Debug.Print newStr\r\n    Debug.Print Len(newStr)             '\u6587\u5b57\u6570\u306e\u78ba\u8a8d\uff0811\uff09\r\n\r\n    \r\n    ' Replace \u95a2\u6570\u3092\u4f7f\u7528\r\n    \r\n    newStr = Replace(myStr, \" \", \"\")    '\u6587\u4e2d\u306b\u3042\u308b\u3059\u3079\u3066\u306e\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u3092\u524a\u9664\r\n    Debug.Print newStr\r\n    Debug.Print Len(newStr)             '\u6587\u5b57\u6570\u306e\u78ba\u8a8d\uff0812\uff09\r\n    \r\n    newStr = Replace(newStr, \"\u3000\", \"\")  '\u6587\u4e2d\u306b\u3042\u308b\u3059\u3079\u3066\u306e\u5168\u89d2\u30b9\u30da\u30fc\u30b9\u3092\u524a\u9664\r\n    Debug.Print newStr\r\n    Debug.Print Len(newStr)             '\u6587\u5b57\u6570\u306e\u78ba\u8a8d\uff0810\uff09\r\n\r\nEnd Sub\r\n\u3000\r\n\r\n<\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/trim01.jpg?ssl=1\" rel=\"lightbox[1770]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/trim01.jpg?resize=400%2C292&#038;ssl=1\" alt=\"Trim \u95a2\u6570 \u4f8b\" width=\"400\" height=\"292\" class=\"alignnone size-medium wp-image-1774\" srcset=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/trim01.jpg?resize=400%2C292&amp;ssl=1 400w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/trim01.jpg?resize=580%2C424&amp;ssl=1 580w, https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/trim01.jpg?w=919&amp;ssl=1 919w\" sizes=\"(max-width: 400px) 100vw, 400px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<br \/><\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>Trim \u95a2\u6570\u30fbLTrim \u95a2\u6570\u30fbRTrim \u95a2\u6570\u306e\u4f7f\u3044\u65b9 \u3010\u66f8\u5f0f\u3011 \uff1c\u5148\u982d\u3068\u672b &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1777,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":"\u6587\u5b57\u5217\uff1a\u6587\u5b57\u5217\u306e\u7a7a\u767d\u3092\u524a\u9664\uff08Trim \u95a2\u6570, LTrim\u95a2\u6570, RTrim\u95a2\u6570\uff09"},"categories":[37],"tags":[207,208,206,63,38,209],"jetpack_featured_media_url":"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2015\/05\/trim01-400x2921.jpg?fit=400%2C292&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-sy","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1770"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=1770"}],"version-history":[{"count":6,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1770\/revisions"}],"predecessor-version":[{"id":1789,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/1770\/revisions\/1789"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/1777"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=1770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=1770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=1770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}