String manipulation issues
Hello all... I've generated a search engine to allow for multiple dropdown selections and a keyword box to return a resultset. Although, the trouble I'm having is redisplaying the keyword accordingly. MS SQL Server 2K8 will handle the keyword as designed for freetext search. Although, when the htmleditformat(form.keyword) value is returned on the page, I'd like the results to appear as followed: Input: "red car" engine Ideal output: "red car" OR engine Basically I need to display the 'ideal output' to the screen that way. Any thoughts how to manipulate this? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:342155 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: String manipulation
> directory="path-to-your-directory" name="dir"> > > I'm going to add to adrian's code here: 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
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
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:312158 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: 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 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: 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
> 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
Why not just use something like: 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: 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
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: 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
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: 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:298258 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
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: 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
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
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
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
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
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? 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
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:247802 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Help with string manipulation please
I was too hasty. The solution I proposed will only work if there is a space. This should always work form.name = trim(form.name); lastspace = REFind("^(.*)[[:space:]]([^[:space:]]+)$",form.name,1,true); if(lastspace.pos[1]){ firstname = Trim(Mid(form.name,lastspace.pos[2],lastspace.len[2])); lastname = Trim(Mid(form.name,lastspace.pos[3],lastspace.len[3])); } else{ firstname = form.name; lastname = ""; } > -Original Message- > From: Pascal Peters > Sent: maandag 14 juni 2004 10:05 > To: CF-Talk > Subject: RE: Help with string manipulation please > > You should collect both names. It is very common in other > languages to have more than one word in a last name. Or what > if hey put their last name first? > > This said > > Lastname = REReplace(form.name,"^.*[[:space:]]","") OR > LastName = ListLast(form.name," ") > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Help with string manipulation please
Thanks for your help with this everyone. I've been on this job for a long time now without a break, and my brain is fading. Not helped by having to work through the night and on a public holiday. Jochem you're quite right, the form should be better, but [A] there's no space on the form page for more fields, and [B] I've inherited the worst case of spaghetti rubbish code I've ever seen, and I can't be totally sure I'm going to find the form code inside an hour and a half. (It took that long to follow the 14 files along the chain to the last form I changed on this site). That's why I'm doing a less than perfect solution on this. If it means there are ill-formed names appearing in the database now, well I'll give the client a price for fixing the form. If I was pricing this job again, it would be at least 8 times the price I quoted, and the deadline would be at least a month rather than a week, simply because of the rotten job the last person did. They're supposedly professional coldfusion developers but I've never seen such a mish-mash of uncommented code in my entire life. In a small site, there are over 350 files, and not a single line of comment anywhere. The file names are no help either. The only way to find what does what is to open a file, follow it along, through all the includes, custom tag calls and cflocations, and look at the functionality. It's a bloody nightmare and that's no lie! I'm so far behind the 8-ball on this deal I'm not going able to give them a single thing that's not on the brief, no matter how desirable it might be for the site. Thanks everyone for your help. I've decided that for better or worse, and cultural differences notwithstanding, I'm going to go with the last word in the 'name' field being the last name, and the rest of the name being firstname. If that causes some issues with data integrity, let them pay me to sort it out. (I guess that's starting to reveal my degree of tiredness of this whole job now) Cheers Mike Kear Windsor, NSW, Australia AFP Webworks http://afpwebworks.com _ From: Jochem van Dieten [mailto:[EMAIL PROTECTED] Sent: Monday, 14 June 2004 5:00 PM To: CF-Talk Subject: Re: Help with string manipulation please I would suggest you rethink the form and let people enter a family name and given name separately. How else are you going to handle people that enter their family name first? [snip] [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Help with string manipulation please
You should collect both names. It is very common in other languages to have more than one word in a last name. Or what if hey put their last name first? This said Lastname = REReplace(form.name,"^.*[[:space:]]","") OR LastName = ListLast(form.name," ") > -Original Message- > From: Michael Kear [mailto:[EMAIL PROTECTED] > Sent: maandag 14 juni 2004 7:36 > To: CF-Talk > Subject: Help with string manipulation please > > I'm trying to work out how to process a form input . > > > > One of the fields on the form is "name" and I need to split > the contents > into "firstname" and "lastname". I realise that some people > might have two > spaces in the name if they choose to enter two firstnames or > if they have a name like Jerry Van Morrison so I want to > strip off the characters > remaining after the last space and call that "lastname". > (If they don't > have any spaces in their input I'm going to consider the > whole thing to be their firstname.) > > > > I've tried quite a few different combinations of find() and > replace() and > mid() but I'm afraid my brain is obviously not going into gear. Can > someone help me please? How do I split "form.name" into > "firstname" and "lastname". (I've already looked at > CFLIB.ORG and can't see anything there that'll do this. > > > > Cheers > > Mike Kear > > Windsor, NSW, Australia > > AFP Webworks > > http://afpwebworks.com > > > > > > > > > > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Help with string manipulation please
name like Jerry Van Morrison so I want to strip off the characters remaining after the last space and call that "lastname". (If they don't have any spaces in their input I'm going to consider the whole thing to be their firstname.) -- How about: [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Help with string manipulation please
Michael Kear said: > > One of the fields on the form is "name" and I need to split the > contents into "firstname" and "lastname". I realise that some > people might have two spaces in the name if they choose to enter two > firstnames or if they have a name like Jerry Van Morrison so I want > to strip off the characters remaining after the last space and call > that "lastname". (If they don't have any spaces in their input > I'm going to consider the whole thing to be their firstname.) I would suggest you rethink the form and let people enter a family name and given name separately. How else are you going to handle people that enter their family name first? > I've tried quite a few different combinations of find() and > replace() and mid() but I'm afraid my brain is obviously not going > into gear. Can someone help me please? How do I split "form.name" > into "firstname" and "lastname". (I've already looked at CFLIB.ORG > and can't see anything there that'll do this. lastname = ListLast(form.name, " ") firstname = Trim(Left(form.name, Len(form.name) - Len(lastname)) Jochem [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Help with string manipulation please
I'm trying to work out how to process a form input . One of the fields on the form is "name" and I need to split the contents into "firstname" and "lastname". I realise that some people might have two spaces in the name if they choose to enter two firstnames or if they have a name like Jerry Van Morrison so I want to strip off the characters remaining after the last space and call that "lastname". (If they don't have any spaces in their input I'm going to consider the whole thing to be their firstname.) I've tried quite a few different combinations of find() and replace() and mid() but I'm afraid my brain is obviously not going into gear. Can someone help me please? How do I split "form.name" into "firstname" and "lastname". (I've already looked at CFLIB.ORG and can't see anything there that'll do this. Cheers Mike Kear Windsor, NSW, Australia AFP Webworks http://afpwebworks.com [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Right() and string manipulation help
If it is alway "item_id", then what you want is always after the 7th character, then how about -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Right() and string manipulation help
Ah, just curious. Thanks! George At 11:53 AM 6/11/2004, Dain Anderson wrote: >This is a pretty simple _expression_, and I would doubt the additional >processing needed is noticeable. The reason I suggested it is because >it's the only sure-fire way of grabbing just the number, irregardless of >the preceeding value, respectfully. > >George Abraham wrote: > > > Is that better performance/resource-wise? Using regular expressions, > > that is? > > > > George > > > > At 11:39 AM 6/11/2004, Dain Anderson wrote: > > >You could use a little RegEx to do that: > > > > > > > > >#REReplace(i, "[^0-9]", "", "ALL")# > > > > > > > > >-Dain > > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Right() and string manipulation help
This is a pretty simple _expression_, and I would doubt the additional processing needed is noticeable. The reason I suggested it is because it's the only sure-fire way of grabbing just the number, irregardless of the preceeding value, respectfully. George Abraham wrote: > Is that better performance/resource-wise? Using regular expressions, > that is? > > George > > At 11:39 AM 6/11/2004, Dain Anderson wrote: > >You could use a little RegEx to do that: > > > > > >#REReplace(i, "[^0-9]", "", "ALL")# > > > > > >-Dain [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Right() and string manipulation help
Sorry Mark... my bad, your code was right. Thanks Dain [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Right() and string manipulation help
Is that better performance/resource-wise? Using regular expressions, that is? George At 11:39 AM 6/11/2004, Dain Anderson wrote: >You could use a little RegEx to do that: > > >#REReplace(i, "[^0-9]", "", "ALL")# > > >-Dain > >cf coder wrote: > > > Hello everybody, > > > > Please can someone show me how to do this. I have a > > comma separated list. > > > > > > item_id11, item_id12, item_id13. > > > > I want to loop through this list and get the > > character(s) after the "item_id" (in this case: > > 1,2,3,11,12,13) > > > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Right() and string manipulation help
I don't want to replace it. I want everything after "item_id" > > >#itemNo# > > >On Fri, 11 Jun 2004 08:30:51 -0700 (PDT), cf coder ><[EMAIL PROTECTED]> wrote: >> [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Right() and string manipulation help
You could use a little RegEx to do that: #REReplace(i, "[^0-9]", "", "ALL")# -Dain cf coder wrote: > Hello everybody, > > Please can someone show me how to do this. I have a > comma separated list. > > > item_id11, item_id12, item_id13. > > I want to loop through this list and get the > character(s) after the "item_id" (in this case: > 1,2,3,11,12,13) > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Right() and string manipulation help
#itemNo# On Fri, 11 Jun 2004 08:30:51 -0700 (PDT), cf coder <[EMAIL PROTECTED]> wrote: > > Hello everybody, > > Please can someone show me how to do this. I have a > comma separated list. > > > item_id11, item_id12, item_id13. > > I want to loop through this list and get the > character(s) after the "item_id" (in this case: > 1,2,3,11,12,13) > > Here is the code I've written: > > > > > Right(ListGetAt(itemList,thisItem),Find("item_id",itemList))> > #itemNo# > > > I would really appreciate your help. > > Regards, > > cfcoder > > __ > Do you Yahoo!? > Friends. Fun. Try the all-new Yahoo! Messenger. > http://messenger.yahoo.com/ > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Right() and string manipulation help
Hello everybody, Please can someone show me how to do this. I have a comma separated list. item_id11, item_id12, item_id13. I want to loop through this list and get the character(s) after the "item_id" (in this case: 1,2,3,11,12,13) Here is the code I've written: Right(ListGetAt(itemList,thisItem),Find("item_id",itemList))> #itemNo# I would really appreciate your help. Regards, cfcoder __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
- Original Message - From: "Pascal Peters" > > You may want to read a bit about regexp. I heard good things about Ben's > book. I've ordered it myself (to use and recommend in my classes), but > it has a hard time getting to Belgium so I haven't read it yet. There is > also http://www.regular-expressions.info/ as an online resource. > I've got this book and was following along nicely until the look ahead. (I haven't read that far in the book yet.) In fact, I had a similar solution going, based on what I'd learned in the book so far. I was having problems with where to say "don't be greedy," though, and was ending up with everything between the first and and the last set of "***"s. (Point being, I second the recommendation for the book.) [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
thank you once again Pascal, I'll get my head stuck in the CFMX reference guide. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
Here you go: [*]{3} ==> three stars \s+ ==> one or more space characters (tab, space, newline, return) (.*?) ==> any number of characters (non greedy: smallest string to match the regexp) \s+ ==> idem [*]{3} ==> idem (.*?) ==> idem (?= ==> positive lookahead (has to be followed by, doesn't remember the group for backreferencing) ([*]{3}\s+.*?\s+[*]{3}) ==> explained before | ==> OR $ ==> end of string ) ==> end positive lookahead \d{1,2} ==> one or two digits / ==> slash \d{2} ==> two digits And so on You may want to read a bit about regexp. I heard good things about Ben's book. I've ordered it myself (to use and recommend in my classes), but it has a hard time getting to Belgium so I haven't read it yet. There is also http://www.regular-expressions.info/ as an online resource. Pascal Peters Certified ColdFusion MX Advanced Developer Macromedia Certified Instructor LR Technologies Av. E. De Mot, 19 1000 BRUSSELS, BELGIUM > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: dinsdag 18 mei 2004 14:26 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > I agree with Pascal, regexps are the most powerfull tools > when it comes to parsing, however they are not easy to code. > Pascal I was wondering if you could explain what your code is doing: > > commentRegexp = > "[*]{3}\s+(.*?)\s+[*]{3}(.*?)(?=([*]{3}\s+.*?\s+[*]{3})|$)"; > timestampRegexp = "\d{1,2}/\d{2}/\d{4}\s+\d{2}:\d{2}:\d{2}"; > > Many thanks [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Another way you could look at this is to check for the length of the total characters in the first line. If it will never be less than 4, then you could wrap it with a conditional statement to check until it finds the first real line that is longer than 4 characters. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
I agree with Pascal, regexps are the most powerfull tools when it comes to parsing, however they are not easy to code. Pascal I was wondering if you could explain what your code is doing: commentRegexp = "[*]{3}\s+(.*?)\s+[*]{3}(.*?)(?=([*]{3}\s+.*?\s+[*]{3})|$)"; timestampRegexp = "\d{1,2}/\d{2}/\d{4}\s+\d{2}:\d{2}:\d{2}"; Many thanks [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
> -Original Message- > From: Stephen Moretti [mailto:[EMAIL PROTECTED] > Sent: dinsdag 18 mei 2004 12:38 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > You end up with a nice wee query of all the log entries for a Do you mean that queries are easier than arrays of structs. I hardly see a difference. Creating a query takes more work, but displaying an array takes more work too. So I think it's a question of personal prefference (or what you need to do with it later). > record, new and old user/date/time stamps are handled, Your code handels old and new comments, but not comments without datestamp. It also doesn't handle user names with spaces in it. > handles comments with multiple lines, it'll be easier to > display the contents of the query, it should work in both CF5 > and CFMX and anyone looking at it later can read the code! The code for cf5 will work in cfmx too, but do you imply that you can't write cfmx specific code and use new features because you want everything to be cf5 compattible? I admit that the code lacked comment, but I have a lot of work at the moment and was writing this quickly to help him out. Are you implying that we shouldn't use regexp, because other developers my not understand it when they read it later? I think regexps is one of the most powerfull tools when it comes to parsing. Just because some people don't understand it, doesn't mean we shouldn't use it. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Thanks Pascal, your script works just fine. Thanks again for your help, most appreciated. Best regards, cfcoder [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
> thisLogLine = trim(ListGetAt(LogField,i)); Whoops Immediately spotted an error : thisLogLine = trim(ListGetAt(LogField,i,chr(13))); Forgot to put the list delimiter in to get one line out of the comments/LogField. Stephen [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
cf coder wrote: > Hi Robert, > > apologies for causing any confusion. I was asked to present the data > stored in the database table column in a certain way. Historically > data stored in this column is as under: > > timestamp > comments > > EX: > > *** 05/12/2003 09:52:10 USER1 *** > closing if fixed - awaitng response from User2 > > I was asked to get rid of the stars and reorder the timestamp to > something like this: > > USER1 05/12/2003 09:52:10 > (Username, Date, Time) > > All comments (timestamps) added henceforth will be added in this fashion. > I hope this gives you a better understanding. The solution Pascal > provided does just that and it does the job for me. > > Best Regards, > cfcoder > Ummm This thread has been going on and on and I can't help but feel that this is overcomplicated this somewhat... Your comment is a string with a number of lines in it. Your date/time stamp is denoted by being started and finished with 3 asterisks. Wouldn't this be simpler? //create new query for this record's Comment/LogField entry thisLogQuery = QueryNew(); QueryAddColumn(thisLogQuery,"UserID"); QueryAddColumn(thisLogQuery,"logDate"); QueryAddColumn(thisLogQuery,"logTime"); QueryAddColumn(thisLogQuery,"Comment"); for (i=1;i lTE ListLen(LogField,chr(13)); i=i+1) { thisLogLine = trim(ListGetAt(LogField,i)); if (ListFirst(thisLogLine," ") EQ "***") { // new date stamp, new row QueryAddRow(thisLogQuery); if (IsDate(ListGetAt(thisLogLine,2," ")){ // Check for old format with date first QuerySetCell(thisLogQuery,"logDate",ListGetAt(thisLogLine,2," ")); QuerySetCell(thisLogQuery,"logTime",ListGetAt(thisLogLine,3," ")); QuerySetCell(thisLogQuery,"UserID",ListGetAt(thisLogLine,4," ")); } else { // otherwise use new format QuerySetCell(thisLogQuery,"UserID",ListGetAt(thisLogLine,2," ")); QuerySetCell(thisLogQuery,"logDate",ListGetAt(thisLogLine,3," ")); QuerySetCell(thisLogQuery,"logTime",ListGetAt(thisLogLine,4," ")); } } else QuerySetCell(thisLogQuery,"Comment",thisLogQuery.Comment[recordcount]&chr(13)&thisLogLine); } You end up with a nice wee query of all the log entries for a record, new and old user/date/time stamps are handled, handles comments with multiple lines, it'll be easier to display the contents of the query, it should work in both CF5 and CFMX and anyone looking at it later can read the code! FOOT NOTE: I just typed this in off the top of my head. I haven't run the code, or checked it in anyway. You may need to tweak it or it might need minor debugging.. Regards Stephen [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
ON CF5 start = 1; aLog = ArrayNew(1); commentRegexp = "[*]{3}[[:space:]]+([^*]*)[[:space:]]+[*]{3}"; timestampRegexp = "[0-9]{1,2}/[0-9]{2}/[0-9]{4}[[:space:]]+[0-9]{2}:[0-9]{2}:[0-9]{2}"; while(true){ stTmp = REFind(commentRegexp,str,start,true); if(stTmp.pos[1]){ stLog = StructNew(); header = Mid(str,stTmp.pos[2],stTmp.len[2]); stTmp2 = REFind(timestampRegexp,header,1,true); if(stTmp2.pos[1]){ stLog.user = Trim(Removechars(header,stTmp2.pos[1],stTmp2.len[1])); stLog.timestamp = Mid(header,stTmp2.pos[1],stTmp2.len[1]); } else{ stLog.user = Trim(header); stLog.timestamp = ""; } stLog.text = ""; if(ArrayLen(aLog)){ aLog[ArrayLen(aLog)].text = Mid(str,start,stTmp.pos[1]-start); } ArrayAppend(aLog,stLog); start = stTmp.pos[1]+stTmp.len[1]; } else{ if(ArrayLen(aLog)){ aLog[ArrayLen(aLog)].text = Trim(Mid(str,start,Len(str)-start)); } break; } } #aLog[i].user# #aLog[i].timestamp# #aLog[i].text# ON CFMX start = 1; aLog = ArrayNew(1); commentRegexp = "[*]{3}\s+(.*?)\s+[*]{3}(.*?)(?=([*]{3}\s+.*?\s+[*]{3})|$)"; timestampRegexp = "\d{1,2}/\d{2}/\d{4}\s+\d{2}:\d{2}:\d{2}"; while(true){ stTmp = REFind(commentRegexp,str,start,true); if(stTmp.pos[1]){ stLog = StructNew(); header = Mid(str,stTmp.pos[2],stTmp.len[2]); stTmp2 = REFind(timestampRegexp,header,1,true); if(stTmp2.pos[1]){ stLog.user = Trim(Removechars(header,stTmp2.pos[1],stTmp2.len[1])); stLog.timestamp = Mid(header,stTmp2.pos[1],stTmp2.len[1]); } else{ stLog.user = Trim(header); stLog.timestamp = ""; } stLog.text = Mid(str,stTmp.pos[3],stTmp.len[3]); ArrayAppend(aLog,stLog); start = stTmp.pos[1]+stTmp.len[1]; } else{ break; } } The script on CF5 breaks if you have * between *** *** The script on CFMX doesn't > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: maandag 17 mei 2004 17:39 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > Thanks Pascal. Sorry again for any inconvenience caused. > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Thanks Pascal. Sorry again for any inconvenience caused. Best regards cfcoder >I'm off to home right now, but I'll send you the code in the morning >(for me GMT+2) > >> [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
I'm off to home right now, but I'll send you the code in the morning (for me GMT+2) > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: maandag 17 mei 2004 17:15 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > sorry Pascal, my bad. The format is not always the same, > there may be few comments in the database without the > timestamp. All comments added when I build the functionality > will not have the *** user timestamp ***. I have CFMX > installed on the server. > > Best regards, > cfcoder > > >If your format isn't always the same (*** user timestamp *** OR *** > >timestamp user ***) you can't use my code. You need to do it in a > >different way. I can help if you want, but if you keep changing the > >specs it's not very easy. Also, remind me what version you > are on. I'm > >writing CF5 regexp for the moment, but this is easier in CFMX. > > > >Pascal > > > >> > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
sorry Pascal, my bad. The format is not always the same, there may be few comments in the database without the timestamp. All comments added when I build the functionality will not have the *** user timestamp ***. I have CFMX installed on the server. Best regards, cfcoder >If your format isn't always the same (*** user timestamp *** OR *** >timestamp user ***) you can't use my code. You need to do it in a >different way. I can help if you want, but if you keep changing the >specs it's not very easy. Also, remind me what version you are on. I'm >writing CF5 regexp for the moment, but this is easier in CFMX. > >Pascal > >> [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Hi Robert, apologies for causing any confusion. I was asked to present the data stored in the database table column in a certain way. Historically data stored in this column is as under: timestamp comments EX: *** 05/12/2003 09:52:10 USER1 *** closing if fixed - awaitng response from User2 I was asked to get rid of the stars and reorder the timestamp to something like this: USER1 05/12/2003 09:52:10 (Username, Date, Time) All comments (timestamps) added henceforth will be added in this fashion. I hope this gives you a better understanding. The solution Pascal provided does just that and it does the job for me. Best Regards, cfcoder > My bad, I responded to Pascal earlier... Sorry about that. > > CFCODER: > > You have shown your data two ways, and this impacts any solution that > is presented: > > Latest: > *** 05/12/2003 09:52:10 USER1 *** > closing if fixed - awaitng response from User2 > > *** 04/12/2003 18:55:18 USER2 *** > Have been there, however user was on air shortly after, will try again > in a bit. > > *** 04/12/2003 18:13:22 USER3 *** > Roger that > > *** 04/12/2003 18:05:01 USER4 *** > closed > > Originally: > > *** User1 10/28/2003 2:53:52 *** > > THIS IS A TEST > > *** User 2 04/06/2003 13:41:47 *** > > blah, blah > > > So which is it? > > Also, I may have missed this answer, but it seems to me that the > solution is to drop the separate data elements into their own fields > in the database IN THE FIRST PLACE. That way they can be queried out, > or barring that solution, change the code that writes each entry to > include delimiters > e.g. > *** User 2|04/06/2003|13:41:47***blah, blah > > And use CR/LF between fields to separate records... > > I'm sorry if this doesn't help, but the fact is you are dealing with > output that sorely needs to be reformatted to make it easier to > process. You shouldn't need anything major to pull it apart. > > Thanks, > Robert > > P.S. What are the rules for the data that you are pulling apart now? > e.g. > 3 asterisks, space date, 2 spaces, time, 2 spaces, username, 2 spaces, > 3 asterisks, comment, cr/lf, cr/lf > 3 asterisks, space date, 2 spaces, time, 2 spaces, username, 2 spaces, > 3 asterisks, comment, cr/lf, cr/lf > etc... > > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: Monday, May 17, 2004 8:32 A > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > > Pascal, sorry again for being such a PEST. I really do apprecaite your > help. > > There can be more than one occurance of the timestamp in the comment > column. Ex: > > *** 05/12/2003 09:52:10 USER1 *** > closing if fixed - awaitng response from User2 > > *** 04/12/2003 18:55:18 USER2 *** > Have been there, however user was on air shortly after, will try again > in a bit. > > *** 04/12/2003 18:13:22 USER3 *** > Roger that > > *** 04/12/2003 18:05:01 USER4 *** > closed > > Can you please add code in your script to handle this and display all > timestamps correctly > > Many thanks again > cfcoder > > > > > > > > >thanks Pascal! It doesn't quite work how I would like it to. > > > >EX: *** 08/12/2003 20:33:31 EDWARI31 *** > > > >You code displays the above timestamp like this: > > > >0 8/12/2003 20:33:31 > > > >Where as I would like it to be displayed like this: > > > >EDWARI31 08/12/2003 20:33:31 > > > >I dumped stTmp . This is what it returns > > > >struct > >LEN > >array > >1 38 > >2 2 > >3 9 > >4 8 > >5 11 > > > >POS > >array > >1 1 > >2 4 > >3 6 > >4 17 > >5 25 > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
If your format isn't always the same (*** user timestamp *** OR *** timestamp user ***) you can't use my code. You need to do it in a different way. I can help if you want, but if you keep changing the specs it's not very easy. Also, remind me what version you are on. I'm writing CF5 regexp for the moment, but this is easier in CFMX. Pascal > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: maandag 17 mei 2004 16:55 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > You are a GENIUS man! That code rocks, I wouldn't know how to > do this without your help. You are a star. Just one small > problem, the comments column sometimes doesn't store the > timestamp. I went through your code. The while condition in > the above mentioned situation would be false so the code in > the else part would be executed. > > if(ArrayLen(aLog)){ > aLog[ArrayLen(aLog)].text = Trim(Mid(str,start,Len(str2)-start)); > } > > The above condition would be false. I added a 'else' > condition and want to assign 'str' to aLog[ArrayLen(aLog)].text. > > something like this: > > if(ArrayLen(aLog)){ > aLog[ArrayLen(aLog)].text = Trim(Mid(str,start,Len(str2)-start)); > } > else > { > 'What should I be doing here?' > } > break; > > Many thanks again! > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
You are a GENIUS man! That code rocks, I wouldn't know how to do this without your help. You are a star. Just one small problem, the comments column sometimes doesn't store the timestamp. I went through your code. The while condition in the above mentioned situation would be false so the code in the else part would be executed. if(ArrayLen(aLog)){ aLog[ArrayLen(aLog)].text = Trim(Mid(str,start,Len(str2)-start)); } The above condition would be false. I added a 'else' condition and want to assign 'str' to aLog[ArrayLen(aLog)].text. something like this: if(ArrayLen(aLog)){ aLog[ArrayLen(aLog)].text = Trim(Mid(str,start,Len(str2)-start)); } else { 'What should I be doing here?' } break; Many thanks again! [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
My bad, I responded to Pascal earlier... Sorry about that. CFCODER: You have shown your data two ways, and this impacts any solution that is presented: Latest: *** 05/12/2003 09:52:10 USER1 *** closing if fixed - awaitng response from User2 *** 04/12/2003 18:55:18 USER2 *** Have been there, however user was on air shortly after, will try again in a bit. *** 04/12/2003 18:13:22 USER3 *** Roger that *** 04/12/2003 18:05:01 USER4 *** closed Originally: *** User1 10/28/2003 2:53:52 *** THIS IS A TEST *** User 2 04/06/2003 13:41:47 *** blah, blah So which is it? Also, I may have missed this answer, but it seems to me that the solution is to drop the separate data elements into their own fields in the database IN THE FIRST PLACE. That way they can be queried out, or barring that solution, change the code that writes each entry to include delimiters e.g. *** User 2|04/06/2003|13:41:47***blah, blah And use CR/LF between fields to separate records... I'm sorry if this doesn't help, but the fact is you are dealing with output that sorely needs to be reformatted to make it easier to process. You shouldn't need anything major to pull it apart. Thanks, Robert P.S. What are the rules for the data that you are pulling apart now? e.g. 3 asterisks, space date, 2 spaces, time, 2 spaces, username, 2 spaces, 3 asterisks, comment, cr/lf, cr/lf 3 asterisks, space date, 2 spaces, time, 2 spaces, username, 2 spaces, 3 asterisks, comment, cr/lf, cr/lf etc... -Original Message- From: cf coder [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 8:32 A To: CF-Talk Subject: Re: help with string manipulation (Find,Replace) Pascal, sorry again for being such a PEST. I really do apprecaite your help. There can be more than one occurance of the timestamp in the comment column. Ex: *** 05/12/2003 09:52:10 USER1 *** closing if fixed - awaitng response from User2 *** 04/12/2003 18:55:18 USER2 *** Have been there, however user was on air shortly after, will try again in a bit. *** 04/12/2003 18:13:22 USER3 *** Roger that *** 04/12/2003 18:05:01 USER4 *** closed Can you please add code in your script to handle this and display all timestamps correctly Many thanks again cfcoder >thanks Pascal! It doesn't quite work how I would like it to. > >EX: *** 08/12/2003 20:33:31 EDWARI31 *** > >You code displays the above timestamp like this: > >0 8/12/2003 20:33:31 > >Where as I would like it to be displayed like this: > >EDWARI31 08/12/2003 20:33:31 > >I dumped stTmp . This is what it returns > >struct >LEN >array >1 38 >2 2 >3 9 >4 8 >5 11 > >POS >array >1 1 >2 4 >3 6 >4 17 >5 25 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
It's like a flat file. (a huge comment field in the DB). Storing the comments in a related table would have made his life easier, but I don't think he can change the way the data is stored. > -Original Message- > From: Bartlett, Robert E. USNUNK NAVAIR 1490, 54-L4 > [mailto:[EMAIL PROTECTED] > Sent: maandag 17 mei 2004 16:37 > To: CF-Talk > Subject: RE: help with string manipulation (Find,Replace) > > Pascal, > > I may have missed the answer to this question, but is the > content that we are looking at a query record set (multiple > records), or is it from like a flat file, where the content > is just appended? > > It seems like all of these solutions are overly complex. It > seems like such a simple problem to resolve. > > Thanks, > Robert [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
Pascal, I may have missed the answer to this question, but is the content that we are looking at a query record set (multiple records), or is it from like a flat file, where the content is just appended? It seems like all of these solutions are overly complex. It seems like such a simple problem to resolve. Thanks, Robert -Original Message- From: Pascal Peters [mailto:[EMAIL PROTECTED] Sent: Monday, May 17, 2004 10:15 A To: CF-Talk Subject: RE: help with string manipulation (Find,Replace) start = 1; aLog = ArrayNew(1); while(true){ stTmp = REFind("[*]{3}([^*]*[[:space:]])([0-9]{1,2}/[0-9]{1,2}/[0-9]{4})[[:space :]]+([0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2})([[:space:]][^*]*)[*]{3}",str,star t,true); if(stTmp.pos[1]){ stLog = StructNew(); stLog = StructNew(); user1 = Mid(str,stTmp.pos[2],stTmp.len[2]); stLog.date = Mid(str,stTmp.pos[3],stTmp.len[3]); stLog.time = Mid(str,stTmp.pos[4],stTmp.len[4]); user2 = Mid(str,stTmp.pos[5],stTmp.len[5]); if(len(trim(user1))) stLog.user = trim(user1); else if(len(trim(user2))) stLog.user = trim(user2); else stLog.user = ""; stLog.text = ""; if(ArrayLen(aLog)){ aLog[ArrayLen(aLog)].text = Mid(str,start,stTmp.pos[1]-start); } ArrayAppend(aLog,stLog); start = stTmp.pos[1]+stTmp.len[1]; } else{ if(ArrayLen(aLog)){ aLog[ArrayLen(aLog)].text = Trim(Mid(str,start,Len(str)-start)); } break; } } #aLog[i].user# #aLog[i].date# #aLog[i].time# #aLog[i].text# > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: maandag 17 mei 2004 14:32 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > Pascal, sorry again for being such a PEST. I really do > apprecaite your help. > > There can be more than one occurance of the timestamp in the > comment column. Ex: > > *** 05/12/2003 09:52:10 USER1 *** > closing if fixed - awaitng response from User2 > > *** 04/12/2003 18:55:18 USER2 *** > Have been there, however user was on air shortly after, will > try again in a bit. > > *** 04/12/2003 18:13:22 USER3 *** > Roger that > > *** 04/12/2003 18:05:01 USER4 *** > closed > > Can you please add code in your script to handle this and > display all timestamps correctly > > Many thanks again > cfcoder > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
start = 1; aLog = ArrayNew(1); while(true){ stTmp = REFind("[*]{3}([^*]*[[:space:]])([0-9]{1,2}/[0-9]{1,2}/[0-9]{4})[[:space :]]+([0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2})([[:space:]][^*]*)[*]{3}",str,star t,true); if(stTmp.pos[1]){ stLog = StructNew(); stLog = StructNew(); user1 = Mid(str,stTmp.pos[2],stTmp.len[2]); stLog.date = Mid(str,stTmp.pos[3],stTmp.len[3]); stLog.time = Mid(str,stTmp.pos[4],stTmp.len[4]); user2 = Mid(str,stTmp.pos[5],stTmp.len[5]); if(len(trim(user1))) stLog.user = trim(user1); else if(len(trim(user2))) stLog.user = trim(user2); else stLog.user = ""; stLog.text = ""; if(ArrayLen(aLog)){ aLog[ArrayLen(aLog)].text = Mid(str,start,stTmp.pos[1]-start); } ArrayAppend(aLog,stLog); start = stTmp.pos[1]+stTmp.len[1]; } else{ if(ArrayLen(aLog)){ aLog[ArrayLen(aLog)].text = Trim(Mid(str,start,Len(str)-start)); } break; } } #aLog[i].user# #aLog[i].date# #aLog[i].time# #aLog[i].text# > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: maandag 17 mei 2004 14:32 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > Pascal, sorry again for being such a PEST. I really do > apprecaite your help. > > There can be more than one occurance of the timestamp in the > comment column. Ex: > > *** 05/12/2003 09:52:10 USER1 *** > closing if fixed - awaitng response from User2 > > *** 04/12/2003 18:55:18 USER2 *** > Have been there, however user was on air shortly after, will > try again in a bit. > > *** 04/12/2003 18:13:22 USER3 *** > Roger that > > *** 04/12/2003 18:05:01 USER4 *** > closed > > Can you please add code in your script to handle this and > display all timestamps correctly > > Many thanks again > cfcoder > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Pascal, sorry again for being such a PEST. I really do apprecaite your help. There can be more than one occurance of the timestamp in the comment column. Ex: *** 05/12/2003 09:52:10 USER1 *** closing if fixed - awaitng response from User2 *** 04/12/2003 18:55:18 USER2 *** Have been there, however user was on air shortly after, will try again in a bit. *** 04/12/2003 18:13:22 USER3 *** Roger that *** 04/12/2003 18:05:01 USER4 *** closed Can you please add code in your script to handle this and display all timestamps correctly Many thanks again cfcoder >thanks Pascal! It doesn't quite work how I would like it to. > >EX: *** 08/12/2003 20:33:31 EDWARI31 *** > >You code displays the above timestamp like this: > >0 8/12/2003 20:33:31 > >Where as I would like it to be displayed like this: > >EDWARI31 08/12/2003 20:33:31 > >I dumped stTmp . This is what it returns > >struct >LEN >array >1 38 >2 2 >3 9 >4 8 >5 11 > >POS >array >1 1 >2 4 >3 6 >4 17 >5 25 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
thanks Pascal! It doesn't quite work how I would like it to. EX: *** 08/12/2003 20:33:31 EDWARI31 *** You code displays the above timestamp like this: 0 8/12/2003 20:33:31 Where as I would like it to be displayed like this: EDWARI31 08/12/2003 20:33:31 I dumped stTmp . This is what it returns struct LEN array 1 38 2 2 3 9 4 8 5 11 POS array 1 1 2 4 3 6 4 17 5 25 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
stTmp = REFind("[*]{3}([^*]+)([0-9]{1,2}/[0-9]{1,2}/[0-9]{4})[[:space:]]+([0-9]{ 1,2}:[0-9]{1,2}:[0-9]{1,2})([^*]+)[*]{3}",str,1,true); user1 = Mid(str,stTmp.pos[2],stTmp.len[2]); date = Mid(str,stTmp.pos[3],stTmp.len[3]); time = Mid(str,stTmp.pos[4],stTmp.len[4]); user2 = Mid(str,stTmp.pos[5],stTmp.len[5]); if(len(trim(user1))) user = trim(user1); else if(len(trim(user2))) user = trim(user2); else user = ""; #user# #date# #time# It's not full proof, but it should work. > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: maandag 17 mei 2004 13:11 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > sorry for being such a pest... I forgot to add in my earlier > post that the timestamp for all existing comments is in the format: > > *** 10/28/2003 2:53:52 User1 *** > > and the timestamp for new comments is: > > *** User1 10/28/2003 2:53:52 *** > > Can you also show me how to display all existing timestamps > in the above format > > Many many thanks in advance. > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
sorry for being such a pest... I forgot to add in my earlier post that the timestamp for all existing comments is in the format: *** 10/28/2003 2:53:52 User1 *** and the timestamp for new comments is: *** User1 10/28/2003 2:53:52 *** Can you also show me how to display all existing timestamps in the above format Many many thanks in advance. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
I figured that out.. thanks stTmp = REFind("[*]{3}[[:space:]]+([^*]+)[[:space:]]+[*]{3}",str,1,true); info = Mid(str,stTmp.pos[2],stTmp.len[2]); #info# the above code works however I was wondering if you could do me another favour. At the minute you are searching for the "***". Would it be possible to come up with a pattern that finds the three stars, username, date and time? ex: *** User1 10/28/2003 2:53:52 *** Its just so its fool proof. My concern is if the column contains three stars somewhere else in the comments then this code would fail. Are you with me? [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Hey Pascal, hope you're doing well buddy! I'm getting an error. The selected method len was not found. Either there are no methods with the specified method name and argument types, or the method len is overloaded with arguments types that ColdFusion can't decipher reliably. If this is a Java object and you verified that the method exists, you may need to use the javacast function to reduce ambiguity. Any idea why? [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
stTmp = REFind("[*]{3}[[:space:]]+([^*]+)[[:space:]]+[*]{3}",str,1,true); info = Mid(str,stTmp.pos[2],stTmp.len(2); #info# > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: vrijdag 14 mei 2004 17:07 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > Pascal or anybody who can help! > > I'm in a similar problem again and need your help. I'm > currently using the code provided by Pascal. The solution to > which is mentioned above. > > I am pulling the data from the 'comments' column in a > database table. The data in the comments column looks like this. > > *** User1 10/28/2003 2:53:52 *** > > THIS IS A TEST > > *** User 2 04/06/2003 13:41:47 *** > > blah, blah > > I want to read everything that's between the *** ie *** User > 1 10/28/2003 2:53:52 *** and display it like this: > User 1 | 14/4/2004 15:58:15 THIS IS A TEST > > Can somebody please show me how to do this using regular expressions? > Many thanks > cf coder > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Pascal or anybody who can help! I'm in a similar problem again and need your help. I'm currently using the code provided by Pascal. The solution to which is mentioned above. I am pulling the data from the 'comments' column in a database table. The data in the comments column looks like this. *** User1 10/28/2003 2:53:52 *** THIS IS A TEST *** User 2 04/06/2003 13:41:47 *** blah, blah I want to read everything that's between the *** ie *** User 1 10/28/2003 2:53:52 *** and display it like this: User 1 | 14/4/2004 15:58:15 THIS IS A TEST Can somebody please show me how to do this using regular expressions? Many thanks cf coder [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
thanks Pascal that explaination makes perfect sense and I understand it. Thanks again for all your help. Best Regards, cfcoder [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
^ start of string \s* any number of whitespace (spaces, tabs, newlines,...) ( start group (for back reference) [*]{3} three stars .+? one or more characters (non greedy match: untill first match of what comes next) [*]{3} three stars .+? one or more characters (non greedy match: untill first match of what comes next) ) end group \s* any number of whitespace (spaces, tabs, newlines,...) (?:[*]{3}.*)? optional group not included in backreference: three stars followed by any number of characters $ end of string \1 backreference to match for first group ([*]{3}.+?[*]{3}.+?) Pascal PS If you don't understand the difference between greedy and non greedy matches, try doing the same on a string with 2 or more comments using .+ instead of .+? > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: donderdag 1 april 2004 11:56 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > Sweet! You are a genius! I can never get my head round > regular expressions. > I don't have a clue what this is actually doing > > regexp = "^\s*([*]{3}.+?[*]{3}.+?)\s*(?:[*]{3}.*)?$"; > str2 = REReplace(str,regexp,"\1"); > > Can you kindly explain it to me because I have to explain it > to my colleague and not look like a fool. Thanks Pascal [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Sweet! You are a genius! I can never get my head round regular expressions. I don't have a clue what this is actually doing regexp = "^\s*([*]{3}.+?[*]{3}.+?)\s*(?:[*]{3}.*)?$"; str2 = REReplace(str,regexp,"\1"); Can you kindly explain it to me because I have to explain it to my colleague and not look like a fool. Thanks Pascal > >*** 13/01/2003 09:47:06 TUser1 *** >callno:1126 >Some comment1 > >*** 13/01/2003 08:30:27 TUser2 *** >Some Comment2 > > > >regexp = "^\s*([*]{3}.+?[*]{3}.+?)\s*(?:[*]{3}.*)?$"; >str2 = REReplace(str,regexp,"\1"); > >#str2# > >This returns the first comment with the datetime & user info. If you >want it without that info the regexp should be > >"^\s*[*]{3}.+?[*]{3}(.+?)\s*(?:[*]{3}.*)?$" > >Watch out for wrapping. There are no spaces in the regexp. > >Pascal > >> [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
*** 13/01/2003 09:47:06 TUser1 *** callno:1126 Some comment1 *** 13/01/2003 08:30:27 TUser2 *** Some Comment2 regexp = "^\s*([*]{3}.+?[*]{3}.+?)\s*(?:[*]{3}.*)?$"; str2 = REReplace(str,regexp,"\1"); #str2# This returns the first comment with the datetime & user info. If you want it without that info the regexp should be "^\s*[*]{3}.+?[*]{3}(.+?)\s*(?:[*]{3}.*)?$" Watch out for wrapping. There are no spaces in the regexp. Pascal > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: woensdag 31 maart 2004 16:55 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > Hi Pascal, I'm really sorry for not getting back to you > yesterday. I've been asked to work on something else. > > I'm trying to display the comment properly and need your > help. I want to display the top most comment from the > comments table. Here is an example. In the example below > there are 2 comments > > *** 13/01/2003 09:47:06 TUser1 *** > callno:1126 > Some comment1 > > *** 13/01/2003 08:30:27 TUser2 *** > Some Comment2 > > I want to display the top most comment. In this case > > *** 13/01/2003 09:47:06 TUser1 *** > callno:1126 > Some comment1 > > All comments have the ***, date time and user information > "*** 13/01/2003 09:47:06 TUser1 ***" > > I would really apprecaite your help. > Best Regards, > cfcoder > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Hi Pascal, I'm really sorry for not getting back to you yesterday. I've been asked to work on something else. I'm trying to display the comment properly and need your help. I want to display the top most comment from the comments table. Here is an example. In the example below there are 2 comments *** 13/01/2003 09:47:06 TUser1 *** callno:1126 Some comment1 *** 13/01/2003 08:30:27 TUser2 *** Some Comment2 I want to display the top most comment. In this case *** 13/01/2003 09:47:06 TUser1 *** callno:1126 Some comment1 All comments have the ***, date time and user information "*** 13/01/2003 09:47:06 TUser1 ***" I would really apprecaite your help. Best Regards, cfcoder [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
To do what? Show me the code of your textarea and any code manipulating the string you display in it and I will try to give you the solution Pascal > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: dinsdag 30 maart 2004 14:23 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > can you show me how to do this? > > >This is for display in HTML, not in a textarea. The tags > would show > >and everything would be on one line > > > >> > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
can you show me how to do this? >This is for display in HTML, not in a textarea. The tags would show >and everything would be on one line > >> [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
This is for display in HTML, not in a textarea. The tags would show and everything would be on one line > -Original Message- > From: Tangorre, Michael [mailto:[EMAIL PROTECTED] > Sent: dinsdag 30 maart 2004 14:22 > To: CF-Talk > Subject: RE: help with string manipulation (Find,Replace) > > #ParagraphFormat(variable)# > > Mike > > > I need your help with something else. This is not related to my > > original query, but related. When the comment field data is > displayed > > in a text area, it looses the new line character. Don't > know why. Here > > is an example. > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
Actually, those 2 lines were meant to replace the cfif's too. You can replace the whole block by my code (but test it anyway!!). For your other problem, I see two possibilities: 1. You are using HTMLEditFormat() to display in the textarea. It replaces CR/LF. Just create a UDF that replaces &,<,>," and use that instead (be sure to replace & first). 2. There is no LF (chr(10)) in your code and that is why it doesn't show. THT Pascal > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: dinsdag 30 maart 2004 12:48 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > Thank you pascal, the code works just the way I want it to. > here it is: > > > > tmp=REReplaceNoCase(qResults.Slug,'^[^a-z0-9_]*([a-z0-9_])','\1')> > > > REReplace(qResults.Slug,"^\s*([*]{3}.*?[*]{3})?\s*","")> > > #str# > > #trim(Left(tmp,Find('#Chr(13)#',tmp)))# > > #tmp# > > > > > I need your help with something else. This is not related to > my original query, but related. When the comment field data > is displayed in a text area, it looses the new line > character. Don't know why. Here is an example. > > MOVE FOLDER *** 04/06/2003 13:41:47 *** blah, blah *** > 04/06/2003 2:33:5" > > When I want display it like this: > > MOVE FOLDER > > *** 04/06/2003 13:41:47 *** > > blah, blah > > *** 04/06/2003 12:33:5" > > Can you show me how to do this please. > Best Regards, > cfcoder [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
#ParagraphFormat(variable)# Mike > I need your help with something else. This is not related to > my original query, but related. When the comment field data > is displayed in a text area, it looses the new line > character. Don't know why. Here is an example. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Thank you pascal, the code works just the way I want it to. here it is: #str# #trim(Left(tmp,Find('#Chr(13)#',tmp)))# #tmp# I need your help with something else. This is not related to my original query, but related. When the comment field data is displayed in a text area, it looses the new line character. Don't know why. Here is an example. MOVE FOLDER *** 04/06/2003 13:41:47 *** blah, blah *** 04/06/2003 2:33:5" When I want display it like this: MOVE FOLDER *** 04/06/2003 13:41:47 *** blah, blah *** 04/06/2003 12:33:5" Can you show me how to do this please. Best Regards, cfcoder >On CFMX only > >// replaces whitespace and date/time before first comment >str = REReplace(str,"^\s*([*]{3}.*?[*]{3})?\s*",""); >// Replaces everything starting from next *** >str = REReplace(str,"^(.*?)\s*[*]{3}.*$","\1"); > >NOT tested, I don't have CFMX running at the moment > >Pascal > >> [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with string manipulation (Find,Replace)
On CFMX only // replaces whitespace and date/time before first comment str = REReplace(str,"^\s*([*]{3}.*?[*]{3})?\s*",""); // Replaces everything starting from next *** str = REReplace(str,"^(.*?)\s*[*]{3}.*$","\1"); NOT tested, I don't have CFMX running at the moment Pascal > -Original Message- > From: cf coder [mailto:[EMAIL PROTECTED] > Sent: maandag 29 maart 2004 13:57 > To: CF-Talk > Subject: Re: help with string manipulation (Find,Replace) > > Many Thanks Yalta for your help. Your code is good but there > it does handle the comments column properly if the comments > column has the following data: > > > > *** 09/05/2002 18:46:21 *** > Closing as no point to this log > Hot Swap > *** 17/04/2002 13:08:15 *** > OK can ayone tell me where the Request for the replacement PC is. > > > I want to display the string "Closing as no point to this log > Hot Swap" whereas if I use your code, the string that's displayed is: > " 09/05/2002 18:46:21 " > > This is my code: > > > > tmp=REReplaceNoCase(qResults.Slug,'^[^a-z0-9_]*([a-z0-9_])','\1')> > > #trim(Left(tmp,Find('***',tmp)-1))# > > #trim(Left(tmp,Find('#Chr(13)#',tmp)))# > > #tmp# > > > > > > > OK, just do something like > > > > '\1'> > > to get rid of all leading characters you do not want, and then use > > sTmp for you Find. > > > > Just a few remarks: > > '^[^a-z0-9_]*([a-z0-9_])' means > > First ^- Start at the start of the string only > > [] one of those inside, with the second ^ - one of those NOT inside > > * - repeated 0 to x times > > () take everything inside and remember it - for a back reference \1 > > later > > The () has to be used to make sure that all leading whitespace is > > removed (ad consequently, you need a back reference later) > > > > > You might want to experiment using a different collection of > > excluded/included chars. There is for example \s for whitespace, \S > > for non-whitespace, but my experiments with those CF-specific > > character class definitions were never too lucky, so I prefer > > enumerating the characters I want/don't want. > > > Yalta > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
Many Thanks Yalta for your help. Your code is good but there it does handle the comments column properly if the comments column has the following data: *** 09/05/2002 18:46:21 *** Closing as no point to this log Hot Swap *** 17/04/2002 13:08:15 *** OK can ayone tell me where the Request for the replacement PC is. I want to display the string "Closing as no point to this log Hot Swap" whereas if I use your code, the string that's displayed is: " 09/05/2002 18:46:21 " This is my code: #trim(Left(tmp,Find('***',tmp)-1))# #trim(Left(tmp,Find('#Chr(13)#',tmp)))# #tmp# > OK, just do something like > > '\1'> > to get rid of all leading characters you do not want, and then use > sTmp for you Find. > > Just a few remarks: > '^[^a-z0-9_]*([a-z0-9_])' means > First ^- Start at the start of the string only > [] one of those inside, with the second ^ - one of those NOT inside > * - repeated 0 to x times > () take everything inside and remember it - for a back reference \1 > later > The () has to be used to make sure that all leading whitespace is > removed (ad consequently, you need a back reference later) > > You might want to experiment using a different collection of > excluded/included chars. There is for example \s for whitespace, \S > for non-whitespace, but my experiments with those CF-specific > character class definitions were never too lucky, so I prefer > enumerating the characters I want/don't want. > Yalta [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: help with string manipulation (Find,Replace)
OK, just do something like to get rid of all leading characters you do not want, and then use sTmp for you Find. Just a few remarks: '^[^a-z0-9_]*([a-z0-9_])' means First ^- Start at the start of the string only [] one of those inside, with the second ^ - one of those NOT inside * - repeated 0 to x times () take everything inside and remember it - for a back reference \1 later The () has to be used to make sure that all leading whitespace is removed (ad consequently, you need a back reference later) You might want to experiment using a different collection of excluded/included chars. There is for example \s for whitespace, \S for non-whitespace, but my experiments with those CF-specific character class definitions were never too lucky, so I prefer enumerating the characters I want/don't want. Yalta [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
help with string manipulation (Find,Replace)
I've tried hard to find a solution to my problem but have had no luck. I am pulling the data from the 'comments' column in a database table. The data in the comments column looks like this. "TEST - CLOSE CALL *** 10/28/2003 2:53:52 *** THIS IS A TEST- PLEASE CLOSE CALL *** 04/06/2003 12:33:5" I want to only display the first comment, in this case "TEST - CLOSE CALL". I am able to do this. Here is the code I've written to display the first comment. #Left(qResults.Slug,Find('#Chr(13)#',qResults.Slug))# The above code searches for a new line in the comment column and displays everything before the new line. The problem I'm having is looking for the first comment (top-most comment) when the data stored in the column begins with a new line " MOVE FOLDER *** 04/06/2003 13:41:47 *** blah, blah *** 04/06/2003 12:33:5" As shown in the above example, there a number of new line characters before the first comment ("Move Folder"). I don't know how to approach this problem, I want to replace all new line characters before the first occurance of a character between a-z. Can someone please show me how to do this please Cheers, cfcoder __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: More string manipulation questions
Thanks! This did catch that there was a blank line at the bottom of the text file! Mitko -- Original Message -- from: "webguy" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] date: Wed, 11 Dec 2002 18:29:28 - >Why not just send the FOCode to the next page and lookup the other values? > >Anyway your error >I'm guessing that there empty line. > > > > > > > > bad string :#fieldofficelist[idxLine]# > > > >WG > >> The output I get does list properly all records but also gives me >> the following error: >> >> Error Diagnostic Information >> >> An error occurred while evaluating the expression: >> >> strFOCode = #trim(listGetAt(strFO,1))# >> >> Error near line 36, column 7. > > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq 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
Re: More string manipulation questions
Here is the full error message (I am not sure why it got cut before): Error Occurred While Processing Request Error Diagnostic Information An error occurred while evaluating the expression: strFOCode = #trim(listGetAt(strFO,1))# Error near line 36, column 7. ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm
RE: More string manipulation questions
Why not just send the FOCode to the next page and lookup the other values? Anyway your error I'm guessing that there empty line. bad string :#fieldofficelist[idxLine]# WG > The output I get does list properly all records but also gives me > the following error: > > Error Diagnostic Information > > An error occurred while evaluating the expression: > > strFOCode = #trim(listGetAt(strFO,1))# > > Error near line 36, column 7. ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq 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
More string manipulation questions
Hello, I have a text file called field_offices.txt which contains information like this: 6BPH, [EMAIL PROTECTED], Albuquerque; 4APH, [EMAIL PROTECTED], Atlanta; 3BPH, [EMAIL PROTECTED], Baltimore; 4CPH, [EMAIL PROTECTED], Birmingham; The meaning is: FOCode, FOEmail, FOName I need to read this text file and use it to populate a drop down menu showing FOName and sending to the next page all three values FOCode, FOEmail and FOName as separate variables. My code is as follows: Index = #idxLine# | Field Office Code = #strFOCode# | Field Office Email = #strFOEmail# | Field Office Name = #strFOName# The output I get does list properly all records but also gives me the following error: Error Diagnostic Information An error occurred while evaluating the expression: strFOCode = #trim(listGetAt(strFO,1))# Error near line 36, column 7. ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.
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 statement catch the "]" character? > > Or a better question is How do i branch on that character... chr(93) doesn't work either. > > > temp = #temp# > > > temp = #temp# Yep It Works! > > > > __ 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 troubles
Sorry All 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 statement catch the "]" character? > >Or a better question is How do i branch on that character... chr(93) doesn't >work either. > > >temp = #temp# > > >temp = #temp# Yep It Works! > > > > __ 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
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 statement catch the "]" character? > >Or a better question is How do i branch on that character... chr(93) doesn't work >either. > > >temp = #temp# > > >temp = #temp# Yep It Works! > > > > > __ 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
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? temp = #temp# temp = #temp# Yep It Works! 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 statement catch the "]" character? > >Or a better question is How do i branch on that character... chr(93) doesn't work >either. > > >temp = #temp# > > >temp = #temp# Yep It Works! > > > > __ 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
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 statement catch the "]" character? Or a better question is How do i branch on that character... chr(93) doesn't work either. temp = #temp# temp = #temp# Yep It Works! __ 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 statement catch the "]" character? Or a better question is How do i branch on that character... chr(93) doesn't work either. temp = #temp# temp = #temp# Yep It Works! __ 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
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 statement catch the "]" character? Or a better question is How do i branch on that character... chr(93) doesn't work either. temp = #temp# temp = #temp# Yep It Works! __ 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
String Manipulation troubles
Why doesn't this statement catch the "]" character? Or a better question is How do i branch on that character... chr(93) doesn't work either. temp = #temp# temp = #temp# Yep It Works! __ 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
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: http://www.cflib.org/foo/goo.html";> http://[^/]*)/.*"> #x# === 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
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
http://www.foobar.com/images/screwy.gif";> #myURL# 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
No - that will return "http: This will work better: http://www.cflib.org/foo/goo.html";> http://[^/]*)/.*"> #x# === 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
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
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
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
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: > > URL.filename 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
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: > >URL.filename 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: URL.filename 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
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: #Item# === 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: > > > > > > > > good one > > > > > > > >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
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: > > > > good one > > > >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