This content has been marked as final. Show 8 replies
Here's one way:
<CFSET YourString = "abc123")>
<CFSET LastChar = "">
<CFSET Pos = 1>
<CFSET CharLen = Len(YourString)>
<CFLOOP from="1" to="#CharLen#" step="1">
<CFSET Char = right(left(YourString,Pos),1)>
<CFIF Not IsNumeric(Char)>
<CFSET LastChar = Char>
<CFSET Pos = Pos + 1>
Here is another one,
I would mark you both as correct if possible thanks for your time guys!
This strikes me as easier...
<CFSET StringToSearch = "1112hjk45P667">
<CFSET NewString = #REReplaceNoCase(StringToSearch, "[^a-z]", "", "ALL")#>
<CFSET LastCharacter = #Right(Trim(NewString),1)#>
Last character in #StringToSearch# is #LastCharacter#
Note that it should return a 'P' based on my example string.
Once again, we see that there are many ways to do the same thing. So when somebody says there is only 1 right way, smack em upside the head with a keyboard. :)
Do we have to wait until they say there is only 1 right way???
Co-workers are like slinkys... not a lot of fun until you push them down the stairs.
> Co-workers are like slinkys... not a lot of fun until you push them down the stairs.
I prefer the shove off the roof in some cases. But swirlies are always good for a laugh.