Remove characters form a string

I am building a field which concatenates a [Work ID] values and [Name of Request] that will be used to name associated files.

Many of the [Name of Request] include characters which are are not allowed in file names (' " / \ # etc.)

How can I replace these characters with an underscore from the string in this formula?

This works for commas..... =[Work ID]@row + " : " + (SUBSTITUTE([Name of Request]@row, ",", "_"))

But, not sure of the syntax to include ' " / \ # ...

This is unpasrable =[Work ID]@row + " : " + (SUBSTITUTE([Name of Request]@row,(",","/",">","." )"_")

Comments

  • Andrée Starå
    Andrée Starå ✭✭✭✭✭✭

    Hi @Detrie Zacharias

    I hope you're well and safe!

    Try something like this, and continue the pattern.

    =[Work ID]@row + ":" + SUBSTITUTE(SUBSTITUTE([Work ID]@row, "/", "_"), "#", "_")
    

    Did that work/help?

    I hope that helps!

    Be safe and have a fantastic week!

    Best,

    Andrée Starå | Workflow Consultant / CEO @ WORK BOLD

    Did my post(s) help or answer your question or solve your problem? Please support the Community by marking it Insightful/Vote Up, Awesome, or/and as the accepted answer. It will make it easier for others to find a solution or help to answer!

    SMARTSHEET EXPERT CONSULTANT & PARTNER

    Andrée Starå | Workflow Consultant / CEO @ WORK BOLD

    W: www.workbold.com | E:andree@workbold.com | P: +46 (0) - 72 - 510 99 35

    Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.

  • Detrie Zacharias
    Detrie Zacharias ✭✭✭✭✭

    Thanks @Andrée Starå

    I'm not sure I follow the syntax

    Do I add a (SUBSTITUTE for each character substitution?

    This throws Unparsable

    =WorkID]@row+":"+SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE([NameofRequest]@row,"/","_"),"#","_")"#","_"),"%","_"),"&","_"),"{","_"),"}","_"),"\","_"),"<","_"),">","_"),"*","_"),"?","_"),"/","_"),"","_"),"$","_"),"!","_"),"'","_"),""","_"),":","_"),"@","_"))

  • Detrie Zacharias
    Detrie Zacharias ✭✭✭✭✭

    I've found the culprits. I was missing a comma and \ backslash

    It fails on backslash "\", "_"

    In the forums I read \ is an escape character and it was recommended to use two "\\"

    This now works as expected.. Thanks for the help

    =[Work ID]@row + "___" + SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE([Name of Request]@row, "/", "_"), "#", "_"), "&", "_"), "%", "_"), "{", "_"), "}", "_"), "<", "_"), ">", "_"), "*", "_"), "?", "_"), "/", "_"), "$", "_"), "!", "_"), "'", "_"), ":", "_"), "@", "_"), "|", "_"), "\\", "_")

  • Andrée Starå
    Andrée Starå ✭✭✭✭✭✭

    @Detrie Zacharias

    Excellent!

    Happy to help!

    Remember! Did my post(s) help or answer your question or solve your problem? Please support the Community by marking it Insightful/Vote Up/Awesome or/and as the accepted answer. It will make it easier for others to find a solution or help to answer!

    SMARTSHEET EXPERT CONSULTANT & PARTNER

    Andrée Starå | Workflow Consultant / CEO @ WORK BOLD

    W: www.workbold.com | E:andree@workbold.com | P: +46 (0) - 72 - 510 99 35

    Feel free to contact me for help with Smartsheet, integrations, general workflow advice, or anything else.

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!