RE: String manipulation
cfdirectory action=READ directory=path-to-your-directory name=dir cfdump var=#dir# Adrian www.adrianlynch.co.uk -Original Message- From: Cherrio [mailto:[EMAIL PROTECTED] Sent: 08 September 2008 08:54 To: CF-Talk Subject: String manipulation hi, am struggling with string manipilation! please help. i have a folder full of files all beginning with a certain prefix then the name of the file is a date + an auto-generated number. eg tesFil_2008090210.txt, tesFil_2008090210.xls, tesFil2008090210.doc As u can see the above files have the same name but different extension. The folder I am working with has a lot of these files but will different names, i need to group the files with the same name and copy them to a different folder. How do I get the file names? Hope this makes sense :) ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312162 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: String manipulation
cfdirectory action=READ directory=path-to-your-directory name=dir cfdump var=#dir# I'm going to add to adrian's code here: cfdirectory action=read name=dir filter=#nameoffile#.* directory=#directory# / The filter attribute of nameoffile.* will return all the files in that directory that have the same name and any extension. Works just like a dos dir command dir nameoffile.* or equivalent *nix command (do wildcards for ls work the same way?) -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312200 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: String Manipulation Fun
Do a ListLen(str, $) to see if the second element is present first. Adrian http://www.adrianlynch.co.uk/ -Original Message- From: Che Vilnonis Sent: 05 February 2008 20:59 To: CF-Talk Subject: String Manipulation Fun Take the following xml string value: 1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $44900 I use the following code to extract and set the price: cfif findNoCase($, theArray[i].description.xmlText) cfset price = listlast(theArray[i].description.xmlText, $) /cfif Sometimes though, the xml data is incomplete and looks like this: 1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $ My current logic bombs on the listlast statement. Any ideas how to fail gracefully and set the price to zero when this happens? Thanks, Che ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:298261 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: String Manipulation Fun
Why not just use something like: cfset parsed = listlast(theArray[i].description.xmlText, ) cfif Len(parsed) GT 1 cfset amount = Right(parsed, Len(parsed)-1 cfelse cfset amount = 0 /cfif Untested... be warned. The only reason I left the dollar sign was to make sure a result came back no matter what for the ListLast. There's probably a better way of doing this though... !k -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 05, 2008 2:59 PM To: CF-Talk Subject: String Manipulation Fun Take the following xml string value: 1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $44900 I use the following code to extract and set the price: cfif findNoCase($, theArray[i].description.xmlText) cfset price = listlast(theArray[i].description.xmlText, $) /cfif Sometimes though, the xml data is incomplete and looks like this: 1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $ My current logic bombs on the listlast statement. Any ideas how to fail gracefully and set the price to zero when this happens? Thanks, Che ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:298264 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: String Manipulation Fun
There's probably a better way of doing this though... There is-- but I think it involves atomic data. :) ~Brad ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:298267 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: String Manipulation Fun
Thanks. Did the trick... -Original Message- From: Adrian Lynch [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 05, 2008 4:06 PM To: CF-Talk Subject: RE: String Manipulation Fun Do a ListLen(str, $) to see if the second element is present first. Adrian http://www.adrianlynch.co.uk/ -Original Message- From: Che Vilnonis Sent: 05 February 2008 20:59 To: CF-Talk Subject: String Manipulation Fun Take the following xml string value: 1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $44900 I use the following code to extract and set the price: cfif findNoCase($, theArray[i].description.xmlText) cfset price = listlast(theArray[i].description.xmlText, $) /cfif Sometimes though, the xml data is incomplete and looks like this: 1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $ My current logic bombs on the listlast statement. Any ideas how to fail gracefully and set the price to zero when this happens? Thanks, Che ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:298268 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: String Manipulation Fun
It seems to me, as a list, that your delimiter is a hyphen, not a dollar symbol trim(listlast(theXMLdata, '-')) or if you don't want the dollar symbol... replace(trim(listlast(theXMLdata, '-')), '$', '') or a regex to grab everything after the $ (if you can guarantee no other dollar symbols) val(rereplace(theXMLdata, .*?\$(.*?), \1)) ..:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -Original Message- From: Che Vilnonis [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 05, 2008 3:59 PM To: CF-Talk Subject: String Manipulation Fun Take the following xml string value: 1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $44900 I use the following code to extract and set the price: cfif findNoCase($, theArray[i].description.xmlText) cfset price = listlast(theArray[i].description.xmlText, $) /cfif Sometimes though, the xml data is incomplete and looks like this: 1969 Chevrolet Camaro - Windsor, ON N8W 5J1 - $ My current logic bombs on the listlast statement. Any ideas how to fail gracefully and set the price to zero when this happens? Thanks, Che ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:298275 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: String Manipulation: get filename out of path
From: [EMAIL PROTECTED] I have this string, C:\CFusionMX7\wwwroot\Inherent\mich_state_bar\PDFS\userguide.pdf I want to parse out the name of the pdf. How do I do this? cfset FileName = GetFileFromPath(C:\CFusionMX7\wwwroot\Inherent\mich_state_bar\PDFS\userguid e.pdf) Sixten ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:247804 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: String Manipulation: get filename out of path
Use the GetFileFromPath() function. There are a very large number of helpful CFML functions built right into the main CFML application servers--as soon as you can find the time, read through them a bit. Josh -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 26, 2006 3:16 PM To: CF-Talk Subject: String Manipulation: get filename out of path I have this string, C:\CFusionMX7\wwwroot\Inherent\mich_state_bar\PDFS\userguide.pdf I want to parse out the name of the pdf. How do I do this? D ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:247805 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: String Manipulation: get filename out of path
Getfilefrompath() Extracts the filename from a fully specified path. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 26, 2006 2:16 PM To: CF-Talk Subject: String Manipulation: get filename out of path I have this string, C:\CFusionMX7\wwwroot\Inherent\mich_state_bar\PDFS\userguide.pdf I want to parse out the name of the pdf. How do I do this? D ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:247806 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: String Manipulation: get filename out of path
We use: #listlast(cgi.SCRIPT_NAME,'/')# ? On 7/26/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have this string, C:\CFusionMX7\wwwroot\Inherent\mich_state_bar\PDFS\userguide.pdf I want to parse out the name of the pdf. How do I do this? D ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:247807 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: String Manipulation: get filename out of path
i was going to say listLast() as well...but getFileFromPath() (as suggested by everyone else so far) sounds like the better option. Either will work, but if I'm looking at my code later and see a getFileFromPath(), I'm going to know exactly what that snippet of code is doing. On 7/26/06, M [EMAIL PROTECTED] wrote: We use: #listlast(cgi.SCRIPT_NAME,'/')# ? On 7/26/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have this string, C:\CFusionMX7\wwwroot\Inherent\mich_state_bar\PDFS\userguide.pdf I want to parse out the name of the pdf. How do I do this? D ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:247809 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: String Manipulation: get filename out of path
On 26 Jul 2006, at 12:34, Charlie Griefer wrote: i was going to say listLast() as well...but getFileFromPath() (as suggested by everyone else so far) sounds like the better option. I assume that getFileFromPath() uses System.getProperty (file.separator) to parse the string, which would be more portable than listLast(). -- Joseph Lamoree ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:247813 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: String Manipulation: get filename out of path
Josh Adams wrote: Use the GetFileFromPath() function. There are a very large number of helpful CFML functions built right into the main CFML application servers--as soon as you can find the time, read through them a bit. I second that motion! I wrote a custom tag back in the CF 4 days to do exactly what I later found out was already handled by GetFileFromPath() DOH! =) Rick ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:247819 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: String Manipulation troubles
First off,trim your var in the if statement and then change the IS to eq. I have had this problem before and by always trimming my vars and using eq instead of is, I have had far less problems like this. HTH Clint -- Original Message -- from: Brian Scandale [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] date: Wed, 26 Jun 2002 00:49:35 -0700 Why doesn't this cfif statement catch the ] character? Or a better question is How do i branch on that character... chr(93) doesn't work either. cfset temp = ] cfoutputbrtemp = #temp#br/cfoutput cfif temp IS ] cfoutputbrtemp = #temp#br/cfoutput Yep It Works! /cfif __ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String Manipulation troubles
Just to make sure it was an email-only typo You did not close the cfset tag with a Jerry Johnson [EMAIL PROTECTED] 06/26/02 11:09AM First off,trim your var in the if statement and then change the IS to eq. I have had this problem before and by always trimming my vars and using eq instead of is, I have had far less problems like this. HTH Clint -- Original Message -- from: Brian Scandale [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] date: Wed, 26 Jun 2002 00:49:35 -0700 Why doesn't this cfif statement catch the ] character? Or a better question is How do i branch on that character... chr(93) doesn't work either. cfset temp = ] cfoutputbrtemp = #temp#br/cfoutput cfif temp IS ] cfoutputbrtemp = #temp#br/cfoutput Yep It Works! /cfif __ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String Manipulation troubles
It works for me Ade -Original Message- From: Brian Scandale [mailto:[EMAIL PROTECTED]] Sent: 26 June 2002 08:50 To: CF-Talk Subject: String Manipulation troubles Why doesn't this cfif statement catch the ] character? Or a better question is How do i branch on that character... chr(93) doesn't work either. cfset temp = ] cfoutputbrtemp = #temp#br/cfoutput cfif temp IS ] cfoutputbrtemp = #temp#br/cfoutput Yep It Works! /cfif __ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String Manipulation troubles
Tried it Clint, see below... It does NOT test True for the Square Bracket. Does this have something to do with Regular Expressions? What's the proper way to test for the ] character? cfset temp = ] cfoutputbrtemp = #temp#br/cfoutput cfif trim(temp) EQ ] cfoutputbrtemp = #temp#br/cfoutput Yep It Works! /cfif At 08:09 AM 6/26/02, you wrote: First off,trim your var in the if statement and then change the IS to eq. I have had this problem before and by always trimming my vars and using eq instead of is, I have had far less problems like this. HTH Clint -- Original Message -- from: Brian Scandale [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] date: Wed, 26 Jun 2002 00:49:35 -0700 Why doesn't this cfif statement catch the ] character? Or a better question is How do i branch on that character... chr(93) doesn't work either. cfset temp = ] cfoutputbrtemp = #temp#br/cfoutput cfif temp IS ] cfoutputbrtemp = #temp#br/cfoutput Yep It Works! /cfif __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String Manipulation troubles
Right... an email typo indeed ;-( At 09:01 AM 6/26/02, you wrote: Just to make sure it was an email-only typo You did not close the cfset tag with a Jerry Johnson [EMAIL PROTECTED] 06/26/02 11:09AM First off,trim your var in the if statement and then change the IS to eq. I have had this problem before and by always trimming my vars and using eq instead of is, I have had far less problems like this. HTH Clint -- Original Message -- from: Brian Scandale [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] date: Wed, 26 Jun 2002 00:49:35 -0700 Why doesn't this cfif statement catch the ] character? Or a better question is How do i branch on that character... chr(93) doesn't work either. cfset temp = ] cfoutputbrtemp = #temp#br/cfoutput cfif temp IS ] cfoutputbrtemp = #temp#br/cfoutput Yep It Works! /cfif __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String Manipulation troubles
Sorry All SOE Stupid Operator Error: It works... I just can't read. That's what I get for 2am morning sessions. Brian At 09:05 AM 6/26/02, you wrote: It works for me Ade -Original Message- From: Brian Scandale [mailto:[EMAIL PROTECTED]] Sent: 26 June 2002 08:50 To: CF-Talk Subject: String Manipulation troubles Why doesn't this cfif statement catch the ] character? Or a better question is How do i branch on that character... chr(93) doesn't work either. cfset temp = ] cfoutputbrtemp = #temp#br/cfoutput cfif temp IS ] cfoutputbrtemp = #temp#br/cfoutput Yep It Works! /cfif __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String Manipulation troubles
According to the documentation, IS and EQ do exactly the same thing, just like IS NOT and NEQ are aliases of one another. Same goes for GREATER THAN and GT, etc.. -Justin Scott, Lead Developer Sceiron Internet Services, Inc. http://www.sceiron.com - Original Message - From: Clint Tredway [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 11:09 AM Subject: Re: String Manipulation troubles First off,trim your var in the if statement and then change the IS to eq. I have had this problem before and by always trimming my vars and using eq instead of is, I have had far less problems like this. HTH Clint -- Original Message -- from: Brian Scandale [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] date: Wed, 26 Jun 2002 00:49:35 -0700 Why doesn't this cfif statement catch the ] character? Or a better question is How do i branch on that character... chr(93) doesn't work either. cfset temp = ] cfoutputbrtemp = #temp#br/cfoutput cfif temp IS ] cfoutputbrtemp = #temp#br/cfoutput Yep It Works! /cfif __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String Manipulation help needed
Try this, ListFirst(http://www.foobar.com/images/screwy.gif;, /) Dave - Original Message - From: Tim Claremont [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, April 23, 2002 2:59 PM Subject: String Manipulation help needed I have the following string: http://www.foobar.com/images/screwy.gif I want to return everything before the third / In other words, I want to retrieve the following: http://www.foobar.com I am sure there is a simple string function. What am I missing? T __ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String Manipulation help needed
Is it just for this string? If so...#Left(string,21)# ...should do it. If for any url (return everything before the third /): then...#Left(sting,Left(/,string,8))# ...should do it. Ryan -Original Message- From: Tim Claremont [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 3:00 PM To: CF-Talk Subject: String Manipulation help needed I have the following string: http://www.foobar.com/images/screwy.gif I want to return everything before the third / In other words, I want to retrieve the following: http://www.foobar.com I am sure there is a simple string function. What am I missing? T __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String Manipulation help needed
No - that will return http: This will work better: cfset theURL = http://www.cflib.org/foo/goo.html; cfset regex = (http://[^/]*)/.* cfset x = REReplace(theURL,regex,\1) cfoutput#x#/cfoutput === Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: Dave Hannum [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 3:14 PM To: CF-Talk Subject: Re: String Manipulation help needed Try this, ListFirst(http://www.foobar.com/images/screwy.gif;, /) Dave - Original Message - From: Tim Claremont [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, April 23, 2002 2:59 PM Subject: String Manipulation help needed I have the following string: http://www.foobar.com/images/screwy.gif I want to return everything before the third / In other words, I want to retrieve the following: http://www.foobar.com I am sure there is a simple string function. What am I missing? T __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String Manipulation help needed
cfset url = http://www.foobar.com/images/screwy.gif; cfset myURL = listGetAt(url,1,'/') // listGetAt(url,2,'/') cfoutput#myURL#/cfoutput This code will do it. You can use the / as list delimiters, in which you're just grabbing the first two items in the list into a variable. Keep in mind that you're not using the 1st and 3rd item in the list because ColdFusion doesn't include empty list items in its count. Eric -Original Message- From: Tim Claremont [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 3:00 PM To: CF-Talk Subject: String Manipulation help needed I have the following string: http://www.foobar.com/images/screwy.gif I want to return everything before the third / In other words, I want to retrieve the following: http://www.foobar.com I am sure there is a simple string function. What am I missing? T __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String Manipulation help needed
Or you could just use the CGI structure to grab info about the host name. I think the one you want is cgi.http_host. - Matt Small -Original Message- From: Dave Hannum [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 3:14 PM To: CF-Talk Subject: Re: String Manipulation help needed Try this, ListFirst(http://www.foobar.com/images/screwy.gif;, /) Dave - Original Message - From: Tim Claremont [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, April 23, 2002 2:59 PM Subject: String Manipulation help needed I have the following string: http://www.foobar.com/images/screwy.gif I want to return everything before the third / In other words, I want to retrieve the following: http://www.foobar.com I am sure there is a simple string function. What am I missing? T __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String Manipulation help needed
Thanks Ray, that one did the trick. I won't even tell ya what I was trying to use... -Original Message- From: Raymond Camden [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 3:21 PM To: CF-Talk Subject: RE: String Manipulation help needed No - that will return http: This will work better: cfset theURL = http://www.cflib.org/foo/goo.html; cfset regex = (http://[^/]*)/.* cfset x = REReplace(theURL,regex,\1) cfoutput#x#/cfoutput === Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: Dave Hannum [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 3:14 PM To: CF-Talk Subject: Re: String Manipulation help needed Try this, ListFirst(http://www.foobar.com/images/screwy.gif;, /) Dave - Original Message - From: Tim Claremont [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, April 23, 2002 2:59 PM Subject: String Manipulation help needed I have the following string: http://www.foobar.com/images/screwy.gif I want to return everything before the third / In other words, I want to retrieve the following: http://www.foobar.com I am sure there is a simple string function. What am I missing? T __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String manipulation
See GetDirectoryFromPath() and GetFileFromPath() At 04:16 AM 10/19/2001, you wrote: Hi, I would like to split the following line into two strings. The length or contents of the string can vary depending on the directory structure. Basically, I need to extract the directory path into one variable and the filename in another. Example: cfoutputURL.filename/cfoutput in my template generates the line below. D:\books\aosl\act_text.dat I need to extract the above into two variables. var1 = D:\books\aosl ~~ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String manipulation
There are functions available to do this for you... getdirectoryfrompath(path) - Extracts a the full directory (including \) from a full path and filename. getfilefrompath(path) - Extracts the filename from a full path and filename. -Justin Scott, Lead Developer Sceiron Internet Services, Inc. http://www.sceiron.com - Original Message - From: phumes1 [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Thursday, October 18, 2001 11:16 AM Subject: Re: String manipulation Hi, I would like to split the following line into two strings. The length or contents of the string can vary depending on the directory structure. Basically, I need to extract the directory path into one variable and the filename in another. Example: cfoutputURL.filename/cfoutput in my template generates the line below. D:\books\aosl\act_text.dat I need to extract the above into two variables. var1 = D:\books\aosl ~~ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String manipulation
Hi, I would like to split the following line into two strings. The length or contents of the string can vary depending on the directory structure. Basically, I need to extract the directory path into one variable and the filename in another. Example: cfoutputURL.filename/cfoutput in my template generates the line below. D:\books\aosl\act_text.dat I need to extract the above into two variables. var1 = D:\books\aosl ~~ Get the mailserver that powers this list at http://www.coolfusion.com FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String manipulation
Hi all, How can extract only the files with the following file extensions .96 from the string below and display the results as Output: 1.96,2.96 test1.txt,test2.txt,test3.txt,file1.96,test4.in,test5.dat,file2.96,file3.96,test6.dat,test5.doc,test5.jb ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String manipulation
If you got this list from a CFDIRECTORY tag, you may want to use the FILTER option instead to automatically only return files named .96. As for finding elements in a list that match .96 (and match at the END), there are a variety of ways. Here is one: CFLOOP INDEX=Item LIST=#List# CFIF ListLen(Item,.) GT 1 AND ListLast(Item,.) IS 96 good one /CFIF /CFLOOP You need the listlen because ListLast(Item,.) will return true if the item is JUST 96, not .96. === Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, September 21, 2001 9:49 AM To: CF-Talk Subject: Re: String manipulation Hi all, How can extract only the files with the following file extensions .96 from the string below and display the results as Output: 1.96,2.96 test1.txt,test2.txt,test3.txt,file1.96,test4.in,test5.dat,file 2.96,file3.96,test6.dat,test5.doc,test5.jb ~~ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String manipulation
How can I display the filenames with the .96 extensions from the CFLOOP. Right now it just displays... good one good one I need file1.96 file2.96 At 10:06 AM 9/21/01 -0400, you wrote: If you got this list from a CFDIRECTORY tag, you may want to use the FILTER option instead to automatically only return files named .96. As for finding elements in a list that match .96 (and match at the END), there are a variety of ways. Here is one: CFLOOP INDEX=Item LIST=#List# CFIF ListLen(Item,.) GT 1 AND ListLast(Item,.) IS 96 good one /CFIF /CFLOOP You need the listlen because ListLast(Item,.) will return true if the item is JUST 96, not .96. === Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, September 21, 2001 9:49 AM To: CF-Talk Subject: Re: String manipulation Hi all, How can extract only the files with the following file extensions .96 from the string below and display the results as Output: 1.96,2.96 test1.txt,test2.txt,test3.txt,file1.96,test4.in,test5.dat,file 2.96,file3.96,test6.dat,test5.doc,test5.jb ~~ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String manipulation
Nevermind. I got it to display the filenames. Thanks for your help Raymond. At 10:06 AM 9/21/01 -0400, you wrote: If you got this list from a CFDIRECTORY tag, you may want to use the FILTER option instead to automatically only return files named .96. As for finding elements in a list that match .96 (and match at the END), there are a variety of ways. Here is one: CFLOOP INDEX=Item LIST=#List# CFIF ListLen(Item,.) GT 1 AND ListLast(Item,.) IS 96 good one /CFIF /CFLOOP You need the listlen because ListLast(Item,.) will return true if the item is JUST 96, not .96. === Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, September 21, 2001 9:49 AM To: CF-Talk Subject: Re: String manipulation Hi all, How can extract only the files with the following file extensions .96 from the string below and display the results as Output: 1.96,2.96 test1.txt,test2.txt,test3.txt,file1.96,test4.in,test5.dat,file 2.96,file3.96,test6.dat,test5.doc,test5.jb ~~ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String manipulation
Oh, notice the INDEX=item code? This says, for every item in the loop, create a variable named item. That's why I check the value of item. So, to display it, just add: CFOUTPUT#Item#/CFOUTPUT === Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, September 21, 2001 10:23 AM To: CF-Talk Subject: RE: String manipulation How can I display the filenames with the .96 extensions from the CFLOOP. Right now it just displays... good one good one I need file1.96 file2.96 At 10:06 AM 9/21/01 -0400, you wrote: If you got this list from a CFDIRECTORY tag, you may want to use the FILTER option instead to automatically only return files named .96. As for finding elements in a list that match .96 (and match at the END), there are a variety of ways. Here is one: CFLOOP INDEX=Item LIST=#List# CFIF ListLen(Item,.) GT 1 AND ListLast(Item,.) IS 96 good one /CFIF /CFLOOP You need the listlen because ListLast(Item,.) will return true if the item is JUST 96, not .96. = == Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, September 21, 2001 9:49 AM To: CF-Talk Subject: Re: String manipulation Hi all, How can extract only the files with the following file extensions .96 from the string below and display the results as Output: 1.96,2.96 test1.txt,test2.txt,test3.txt,file1.96,test4.in,test5.dat,file 2.96,file3.96,test6.dat,test5.doc,test5.jb ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String manipulation
Martin wrote: ...so when in the loop how do I parse the current line.. eg..check the current line for certain characters, and if it passes the check I copy the string to a new entry in an array. Try this within the loop Steve suggested: cfif Find(idx, "some string") neq 0 cfset some_array[ArrayLen(some_array)+1][1] = idx /cfif That's assuming you want to capture the whole line. Also note that a structure might be an easier solution than an array unless you need the multi-dimensionality. If you use an array, don't forget to define it prior to the loop with ArrayNew(x) where x is the number of required dimensions. Valid numbers are 1-3. Charles [EMAIL PROTECTED] ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String manipulation
It would be great if you could help me out..give me some sample code..names of functions taht I will need to do this..or all of the above..thanks :-) These are what I call the "string operator" functions. You will need most of these. http://cfhub.com/language/INDEX.CFM?Cat=String%20Operators Also, pull the whole file with CFHTTP, and save it. then just use CFFILE for the rest. Of particular interest are the Find() and mid() functions. This is a script that pulls/parses data: http://cfhub.com/advanced/cfhttp/post.cfm and I have many more : ) Parsing is kind of a hobby of mine... If you like, email me off list... [EMAIL PROTECTED] ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: String manipulation
Thanks for that, I know most of the string functions...but how do I do a mid (string,start,end) which starts at the beginning of a line, and gets a copy of the complete line...and then repeat this for every line in the text file?? I guess i don't know how I can determine thevales for the start, end params. Any ideas? From: "Joseph Thompson" [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Subject: Re: String manipulation Date: Tue, 12 Dec 2000 17:05:39 -0800 It would be great if you could help me out..give me some sample code..names of functions taht I will need to do this..or all of the above..thanks :-) These are what I call the "string operator" functions. You will need most of these. http://cfhub.com/language/INDEX.CFM?Cat=String%20Operators Also, pull the whole file with CFHTTP, and save it. then just use CFFILE for the rest. Of particular interest are the Find() and mid() functions. This is a script that pulls/parses data: http://cfhub.com/advanced/cfhttp/post.cfm and I have many more : ) Parsing is kind of a hobby of mine... If you like, email me off list... [EMAIL PROTECTED] ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String manipulation
If you're trying to parse a text file line by line, it's typically done by looping over the file, as a list, using an appropriate EOL character(s) as the delimiter. In this case I'll use ASCII character 13, the carriage return. Try something like this (if it's what you need): CFSET int_count = 0 CFLOOP List="#FileContents#" Delimiters="#Chr(13)#" Index="idx" CFSET int_count = (int_count + 1) CFOUTPUT !--- 'idx' will be a line of the file --- !--- Ex. Line 1: This is the first line. Line 2: This is the second line. --- Line #int_count#: #idx#br /CFOUTPUT /CFLOOP Steve -Original Message- From: Martin S [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 12, 2000 11:04 PM To: CF-Talk Subject: Re: String manipulation Thanks for that, I know most of the string functions...but how do I do a mid (string,start,end) which starts at the beginning of a line, and gets a copy of the complete line...and then repeat this for every line in the text file?? I guess i don't know how I can determine thevales for the start, end params. Any ideas? From: "Joseph Thompson" [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Subject: Re: String manipulation Date: Tue, 12 Dec 2000 17:05:39 -0800 It would be great if you could help me out..give me some sample code..names of functions taht I will need to do this..or all of the above..thanks :-) These are what I call the "string operator" functions. You will need most of these. http://cfhub.com/language/INDEX.CFM?Cat=String%20Operators Also, pull the whole file with CFHTTP, and save it. then just use CFFILE for the rest. Of particular interest are the Find() and mid() functions. This is a script that pulls/parses data: http://cfhub.com/advanced/cfhttp/post.cfm and I have many more : ) Parsing is kind of a hobby of mine... If you like, email me off list... [EMAIL PROTECTED] ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: String manipulation
Thanks again, That looks closer to what I want.. ...so when in the loop how do I parse the current line.. eg..check the current line for certain characters, and if it passes the check I copy the string to a new entry in an array. From: "Steve Bernard" [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Subject: RE: String manipulation Date: Wed, 13 Dec 2000 00:56:36 -0500 If you're trying to parse a text file line by line, it's typically done by looping over the file, as a list, using an appropriate EOL character(s) as the delimiter. In this case I'll use ASCII character 13, the carriage return. Try something like this (if it's what you need): CFSET int_count = 0 CFLOOP List="#FileContents#" Delimiters="#Chr(13)#" Index="idx" CFSET int_count = (int_count + 1) CFOUTPUT !--- 'idx' will be a line of the file --- !--- Ex. Line 1: This is the first line. Line 2: This is the second line. --- Line #int_count#: #idx#br /CFOUTPUT /CFLOOP Steve -Original Message- From: Martin S [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 12, 2000 11:04 PM To: CF-Talk Subject: Re: String manipulation Thanks for that, I know most of the string functions...but how do I do a mid (string,start,end) which starts at the beginning of a line, and gets a copy of the complete line...and then repeat this for every line in the text file?? I guess i don't know how I can determine thevales for the start, end params. Any ideas? From: "Joseph Thompson" [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Subject: Re: String manipulation Date: Tue, 12 Dec 2000 17:05:39 -0800 It would be great if you could help me out..give me some sample code..names of functions taht I will need to do this..or all of the above..thanks :-) These are what I call the "string operator" functions. You will need most of these. http://cfhub.com/language/INDEX.CFM?Cat=String%20Operators Also, pull the whole file with CFHTTP, and save it. then just use CFFILE for the rest. Of particular interest are the Find() and mid() functions. This is a script that pulls/parses data: http://cfhub.com/advanced/cfhttp/post.cfm and I have many more : ) Parsing is kind of a hobby of mine... If you like, email me off list... [EMAIL PROTECTED] ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists