{"id":65,"date":"2016-07-01T14:03:08","date_gmt":"2016-07-01T14:03:08","guid":{"rendered":"http:\/\/www.morematter.net\/?p=65"},"modified":"2016-07-01T14:03:08","modified_gmt":"2016-07-01T14:03:08","slug":"strip-trailing-or-repeated-delimiters-in-a-cf-list","status":"publish","type":"post","link":"https:\/\/experimentalism.net\/morematter\/strip-trailing-or-repeated-delimiters-in-a-cf-list\/","title":{"rendered":"Strip trailing, or repeated, delimiters in a CF list"},"content":{"rendered":"<p>Found a helpful trick at http:\/\/stackoverflow.com\/questions\/182455\/coldfusion-and-trailing-comma &#8211;<br \/>\nif you want to clean up a list in ColdFusion, take advantage of the fact that CF list functions ignore empty elements. ListChangeDelims() consequently strips off that last &#8220;element&#8221;.<\/p>\n<p><code><br \/>\n   var cleanList = ListChangeDelims(DirtyList, \",\", \",\");<br \/>\n<\/code><\/p>\n<p>For example, I often need this when building an url or file path, especially when a base path is configurable and may or may not have a trailing slash, and depending how the dynamic path is built, it may or not end up with another trailing slash. E.g., <\/p>\n<p><code><br \/>\n   var pathSeparator = createObject(\"java\",\"java.io.File\").separator;<br \/>\n   var path = ListChangeDelims(listAppend(getConfigBean().getProperty('path_base_directory'), \"subdir\", pathSeparator), pathSeparator, pathSeparator);<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Found a helpful trick at http:\/\/stackoverflow.com\/questions\/182455\/coldfusion-and-trailing-comma &#8211; if you want to clean up a list in ColdFusion, take advantage of the fact that CF list functions ignore empty elements. ListChangeDelims() consequently strips off that last &#8220;element&#8221;. var cleanList = ListChangeDelims(DirtyList, &#8220;,&#8221;, &#8220;,&#8221;); For example, I often need this when building an url or file path, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-coldfusioncfmlcfscript"],"_links":{"self":[{"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":2,"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/posts\/65\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/experimentalism.net\/morematter\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}