{"id":253,"date":"2010-06-25T00:00:34","date_gmt":"2010-06-25T04:00:34","guid":{"rendered":"http:\/\/erics-test-lab.com\/?p=253"},"modified":"2010-06-25T00:00:34","modified_gmt":"2010-06-25T04:00:34","slug":"coldfusion-rereplace","status":"publish","type":"post","link":"https:\/\/www.esearing.com\/v2010\/2010\/06\/coldfusion-rereplace\/","title":{"rendered":"ColdFusion ReReplace"},"content":{"rendered":"<p>Avery useful function for dealing with strings. Uses a regular expression (RE) to search a string for a string pattern and replace it with another. The search is case-sensitive, and it has attributes you can set to control case.<\/p>\n<p>REReplace(string, reg_expression, substring [, scope ])<!--more--><\/p>\n<p>Since there is no Proper Case or Title Case in CF we can use REReplace to do it.<br \/>\n<code>#rereplace( \"erics test lab\", \"b([a-z])\", \"U1\", \"ALL\")#<br \/>\nyields: Erics Test Lab<\/code><\/p>\n<p>Or use it to modify spaces from strings to create URLs.<br \/>\n<code>cfset myUrl=\"#rereplace( \"Erics Test Lab\", \" \", \"-l\", \"ALL\")# .com\"<br \/>\nyields: myUrl=\"erics-test-lab.com\"<\/code><\/p>\n<p>Don&#8217;t forget the scope variable. Valid values are 1 (default) or ALL. You can use this as part of SQL statements or CFIF logic or even to edit text. The string to replace can be a dynamic variable too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Avery useful function for dealing with strings. Uses a regular expression (RE) to search a string for a string pattern and replace it with another. The search is case-sensitive, and it has attributes you can set to control case. REReplace(string, &hellip; <a href=\"https:\/\/www.esearing.com\/v2010\/2010\/06\/coldfusion-rereplace\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,16,24],"tags":[],"class_list":["post-253","post","type-post","status-publish","format-standard","hentry","category-code","category-coldfusion","category-snippets-quick-code-tips-for-single-elements-attributes-or-details"],"_links":{"self":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/comments?post=253"}],"version-history":[{"count":0,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/253\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/media?parent=253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/categories?post=253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/tags?post=253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}