Skip to main content
Participating Frequently
August 10, 2009
Question

Replace Function

  • August 10, 2009
  • 1 reply
  • 927 views

Hello All,
The code below does the following: It finds an item in Spanish (in this case it's GetBasket.options, 2) and adds `SPA` to the SKU code.

<cfif ListContains(GetBasket.options, 2)><option value="2"><cfset basketsku = GetBasket.SKU & "SPA"></option></cfif>

How do I do the following?

Instead of adding SPA at the end I need to replace a third character in the SKU with number 3. For example: the SKU code in English is 902013, but the SKU code for Spanish is 903013. As you can see the 3rd number is being replaced with 3. It will be standard for all items in Spanish. How do I modify the code above to replace the 3rd number with 3?

Thank you all very much in advance!

    This topic has been closed for replies.

    1 reply

    Inspiring
    August 10, 2009

    newString = left(oldString, 2) & "3" & right(oldString, len(oldString - 3);

    Participating Frequently
    August 10, 2009

    Thank you Dan very much. Would it be possible implement what you wrote into existing code that I provided above?

    Thanks!