<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>WebDH blog - RegEx</title>
			<link>http://blog.webdh.com/index.cfm</link>
			<description>This is Troy&apos;s blog for WebDH.com LLC.</description>
			<language>en-us</language>
			<pubDate>Mon, 06 Sep 2010 13:05:24 -0700</pubDate>
			<lastBuildDate>Wed, 27 Feb 2008 09:49:00 -0700</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>webdh.com@gmail.com</managingEditor>
			<webMaster>webdh.com@gmail.com</webMaster>
			
			<item>
				<title>Using ColdFusion and RegEx on a special file naming convention</title>
				<link>http://blog.webdh.com/index.cfm/2008/2/27/Using-RegEx-on-a-special-file-naming-convention</link>
				<description>
				
				I had a project where we had a graphics library, and a bunch of zip files were placed in a directory. The zip files contained 1 or more images packaged up. It was mostly used for product shots to show views of front, back, left, or right. Each zip file could have an associated thumbnail preview image. The files followed a special naming convention, with file names in a format of: SUBJ_DESC_VIEW_FORMAT_TYPE.zip. I used a RegEx (regular expression), as well as the Find() function to parse the file name.

SUBJ is the subject, and should describe the file, and helps order the files alphabetically in the directory.

DESC is the description, such as: LOGO, Model, Version-3, etc.  (hint: you can lengthen the description with up to 3 dashes -&apos;s)

VIEW is optional, and can be either: Ft (front), Rt (right), Lt (left), or Bk (back)

FORMAT can be either: PPT, PRINT, or WEB

TYPE is optional, and can be either: EPS, JPG, TIF

A thumbnail preview can be used, and must be named: SUBJ_DESC_VIEW_thumb.gif (or .jpg). If VIEW was used for the zip file name, it must also be used in the thumbnail file name.

Example zip file: UTM_1100D_Ft_PRINT_EPS.zip

Example thumb file: UTM_1100D_Ft_thumb.gif

Here was the code I used to parse the file name and display a friendly version without dashes to the user. 
&lt;code&gt;
&lt;cfsavecontent variable=&quot;file_desc&quot;&gt;
&lt;cfset found = REFind(&quot;\_[[:alnum:]]+\-*[[:alnum:]]*\-*[[:alnum:]]*\-*[[:alnum:]]*\-*[[:alnum:]]*\-*[[:alnum:]]*\_&quot;,name,0,&quot;TRUE&quot;)&gt;

&lt;!--- grab the description out of the file name, replacing dashes with spaces ---&gt;
&lt;cfif found.pos[1]&gt;#Replace(Mid(name,found.pos[1]+1,found.len[1]-2),&quot;-&quot;,&quot; &quot;,&quot;ALL&quot;)#&lt;/cfif&gt;

&lt;!--- tell user which view ---&gt;
&lt;cfif FindNoCase(&quot;_Ft&quot;,name,1)&gt;
	(Front view)
&lt;cfelseif FindNoCase(&quot;_Rt&quot;,name,1)&gt;
	(Right view)
&lt;cfelseif FindNoCase(&quot;_Lt&quot;,name,1)&gt;
	(Left view)
&lt;cfelseif FindNoCase(&quot;_Bk&quot;,name,1)&gt;
	(Back view)
&lt;/cfif&gt;

&lt;!--- tell user what file type(s) ---&gt;
&lt;cfif Find(&quot;_EPS&quot;,name,1)&gt;
	(EPS High-Res)
&lt;cfelseif Find(&quot;_JPG&quot;,name,1)&gt;
	(JPG High-Res)
&lt;cfelseif Find(&quot;_TIF&quot;,name,1)&gt;
	(TIFF High-Res)
&lt;cfelseif Find(&quot;_PPT&quot;,name,1)&gt;
	(PowerPoint)
&lt;cfelseif Find(&quot;_WEB&quot;,name,1)&gt;
	(WEB Low-Res)
&lt;cfelseif Find(&quot;_PRINT&quot;,name,1)&gt;
	(PRINT High-Res)
&lt;/cfif&gt;
&lt;/cfsavecontent&gt;
&lt;cfif Not Len(Trim(file_desc))&gt;
	File: #name#
&lt;cfelse&gt;
	#file_desc#
&lt;/cfif&gt;
&lt;/code&gt;
Here is an example of what the parsing accomplished.

Example zip file: UTM_Model-1100D-Silver_Ft_PRINT_EPS.zip

The user would see:
Model 1100D Silver (Front view) (EPS High-Res) 
				</description>
				
				<category>RegEx</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Wed, 27 Feb 2008 09:49:00 -0700</pubDate>
				<guid>http://blog.webdh.com/index.cfm/2008/2/27/Using-RegEx-on-a-special-file-naming-convention</guid>
				
			</item>
			
			<item>
				<title>Speedy CSV file parsing using ColdFusion</title>
				<link>http://blog.webdh.com/index.cfm/2007/10/15/Speedy-CSV-file-parsing</link>
				<description>
				
				A client of mine needed a solution to bulk import CSV files of affiliate coupon data into his database. I found a great blog by Ben Nadel who covered the exact topic I was looking for:
&lt;a href=&quot;http://www.bennadel.com/index.cfm?dax=blog:991.view&quot;&gt;CSVToArray() ColdFusion UDF For Parsing CSV Data / Files&lt;/a&gt;

After I implemented Ben&apos;s function, we were able to import 1000 records in about 1.6 seconds. Not bad, considering it used to take him hours of time to manually input the coupons one at a time.

Thanks Ben (and Steven Levithan who helped improve the RegEx) 
				</description>
				
				<category>RegEx</category>				
				
				<category>ColdFusion</category>				
				
				<pubDate>Mon, 15 Oct 2007 13:23:00 -0700</pubDate>
				<guid>http://blog.webdh.com/index.cfm/2007/10/15/Speedy-CSV-file-parsing</guid>
				
			</item>
			</channel></rss>