Skip to main content
September 5, 2022
Question

Replace All Occurrences of a Substring in a String

  • September 5, 2022
  • 3 replies
  • 3 views

What is the APPIAN's equivalent for  JS String.replaceAll ? 

    3 replies

    September 6, 2022

    you can use substitute function for this.

    for example: substitute(
    "ACTUAL_TEXT","SUB_STRING","TO_REPLACE_WITH"
    )

    mikes0011
    Brainy
    September 6, 2022

    Appian OOTB substitute() works fine for any basic use cases as DeepakG already mentioned above.  Just chiming in to add, that for more advanced use cases (fuzzy / pattern-matching / etc), you can also use "regexReplaceAll()" found in the Regex plug-in.

    The Expression Guru
    rahata9316
    September 7, 2022

    If you can check if reduce can give this the desired result also. Somewhere in community I read this last time.

    if(
      count(ri!originalValues) <> count(ri!replacementValues),
      ri!inputText,
    
      reduce(
        fn!substitute,
        ri!inputText,
        merge( ri!originalValues, ri!replacementValues )
      )
    )