Removing set number of characters from end of string with ColdFusion
Asked Answered
W

1

13

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!

Worldbeater answered 25/6, 2010 at 15:45 Comment(0)
S
33
Left(mystring, len(mystring)-6)
Surfboat answered 25/6, 2010 at 15:50 Comment(4)
Great! I think my brain has melted due to the fact it's hot and it's Friday. Thanks for your help!Worldbeater
It really is too bad that coldfusion does not support negative numbers in its string functions like many other languages do.Surfboat
If enough people ask for it, it might get added - feature requests can be made here: adobe.com/cfusion/mmform/index.cfm?name=wishformOptical
If 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 :) :)Catchpenny

© 2022 - 2024 — McMap. All rights reserved.