Dear guys, Anyone know how to display the value only after the “-†from “Singapore , Singapore - Bangkok, Thailand†in coldfusion. It means I just need to display “Bangkok, Thailand†instead of whole string. Thanks in advance!
Search on "coldfusion split." cflib.org has a udf for a split function. Then you can split on '-'. So something like <cfset arrMySplit = Split( InStr, '-')> <cfoutput>#arrMySplit [2]#</cfoutput> <!--- CF arrays are 1 based -->
Just do a ListGetAt <cfset String ="Singapore , Singapore - Bangkok, Thailand"> <cfoutput>#ListGetAt(string, 2, '-')#</cfoutput>
Or you could do this: <cfset string = "Singapore, Singapore - Bangkok, Thailand" /> <cfset string = replace(string, #string# , "Bangkok, Thailand", "one")
except that is assuming the string isnt dynamically generated - the list get at works with a dynamic string