Removing set number of characters from end of string with ColdFusion
16,594
Left(mystring, len(mystring)-6)
Related videos on Youtube
Author by
Simon Hume
Updated on April 25, 2022Comments
-
Simon Hume about 2 years
Simple request (hopefully) here.
I have a string which whilst it varies in length, will always need the last 6 characters removed.
Using a 3rd party web service, so I'm unable to edit the response in the XML before outputting.
If anyone can suggest a quick way of trimming them off i'd be really grateful!
here is the string i'll be using:
#daysEvent[iItem].XmlChildren[iEvent].XmlChildren[16].XmlText#
Thanks!
-
Simon Hume almost 14 yearsGreat! I think my brain has melted due to the fact it's hot and it's Friday. Thanks for your help!
-
DaEagle almost 14 yearsIt really is too bad that coldfusion does not support negative numbers in its string functions like many other languages do.
-
Peter Boughton almost 14 yearsIf enough people ask for it, it might get added - feature requests can be made here: adobe.com/cfusion/mmform/index.cfm?name=wishform
-
Husnain Iqbal over 9 yearsIf we have <cfset currentDateTime=Now()> i.e. <cfset currentDateTime= "{ts '2014-08-19 02:33:07'}"> THEN <cfset currentDateTime = Left(currentDateTime, len(currentDateTime)-2)> <cfset currentDateTime = Right(currentDateTime, len(currentDateTime)-5)> WILL RESULT 2014-08-19 02:33:07 :) :)