lulu50
asked on
Get Last Value from string
Hi,
I have created a cookie with this value:
<cfcookie name="GetIPUser" value="#ipaddress#,22" expires="30">
output
12.176.249.232,22
how can I just get the last value "22" right after the commas.
<cfset NewValue2 = (cookie.GetIPUser) "Note: I just need the value 22 to be here >
<cfset NewValue1 = (cookie.GetIPUser) "Note: I just need the value 12.176.249.232 to be here >
I have created a cookie with this value:
<cfcookie name="GetIPUser" value="#ipaddress#,22" expires="30">
output
12.176.249.232,22
how can I just get the last value "22" right after the commas.
<cfset NewValue2 = (cookie.GetIPUser) "Note: I just need the value 22 to be here >
<cfset NewValue1 = (cookie.GetIPUser) "Note: I just need the value 12.176.249.232 to be here >
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cfEngineers:
Great!!!
Thank you
Great!!!
Thank you
ASKER
Thank you Great!!!
sorry misread what you want
<cfset last = listlast("12.176.249.232,2 2", ",")>
<cfset first = listfirst("12.176.249.232, 22", ",")>
<cfoutput>#first#<br>#last #</cfoutpu t>
<cfset last = listlast("12.176.249.232,2
<cfset first = listfirst("12.176.249.232,
<cfoutput>#first#<br>#last
Use list last with a . as delimiter
<cfset last = listlast("12.176.249.232.2
<cfoutput>#last#</cfoutput