Link to home
Start Free TrialLog in
Avatar of lulu50
lulu50Flag for United States of America

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 >
ASKER CERTIFIED SOLUTION
Avatar of cfEngineers
cfEngineers

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SidFishes

Use list last with a . as delimiter

<cfset last = listlast("12.176.249.232.22", ".")>

<cfoutput>#last#</cfoutput>
Avatar of lulu50

ASKER

cfEngineers:

Great!!!
Thank you
Avatar of lulu50

ASKER

Thank you Great!!!
sorry misread what you want

<cfset last = listlast("12.176.249.232,22", ",")>
<cfset first = listfirst("12.176.249.232,22", ",")>
<cfoutput>#first#<br>#last#</cfoutput>