The way you're using right() and replace() is incorrect.

RIGHT(URL.GROUPS, 1) will return the last character in the string. In this
case, a comma.

Then with replace(), you're using the result of right() (the comma) and
replacing the first instance (and only the first, since you didn't specify
"ALL" in replace) within URL.GROUPS with nothing.

What you intended to do is strip off the last character. You should do some
checking to make sure there is in fact an extraneous comma at the end, and
then do something like this:

<cfset URL.Group = left(URL.GROUPS,len(URL.GROUPS)-1)>

That will take the leftmost X characters (X being one less than the total
length of the string).

It's not necessarily pretty, but it accomplishes what you are trying to do.

Rob


-----Original Message-----
From: Bruce Sorge [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 24, 2007 2:21 PM
To: CF-Talk
Subject: Trouble with RIGHT function

I have a query that is getting a string for the WHERE clause from the a URL
variable, and I am building the URL variable in JS on the form submit. What
happens is that the JS puts a comma at the end of the string. No big deal. I
figured that I would just use the RIGHT function to rebuild the string on
the submitted page, stripping the comma off the end. However, it is not
working. The original string looks like this:

3, 4, 5, 6,

When I do this:

<cfset URL.Group = REPLACE(URL.GROUPS, RIGHT(URL.GROUPS, 1),'')>

I get 3 4, 5, 6,

I am not sure why this is happening. The only thing that I can think of is
that the space between the comma and number is making CF think that 3, is
the end of the string. Does this sound correct?

Thanks,

-- 
Bruce Sorge

"I'm a mawg: half man, half dog. I'm my own best friend!"




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276150
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to