Skip to main content
shubhama926776
Brainy
June 1, 2022
Solved

How to Replace Special Characters("\\\\/;:“|?’][*") from Document Name(Text) with "_"

  • June 1, 2022
  • 2 replies
  • 0 views

I am generating document but document name may contains special characters like ("\\/;:“|?’><*") but i want to replace this characters with "_".
Any quick solution?

Text : "Data/S Load:?"

Expected : "Data_S Load__"

    Best answer by gabriele.camilli

    In alternative to the good answer of Stefan, an alternative is to use regexreplace on any non word character to _

    2 replies

    stefanhelzle0001
    Brainy
    June 1, 2022

    This replaces all characters in the list in line 4 with the character in line 5.

    reduce(
      substitute(_,_,_),
      "=)(/&%$§%<>sahggfsah**'#/\||",
      {"\", "\", "/", ";", ":", """", "|", "?", "â`™", ">", "<", "*"},
      "_"
    )

    gabriele.camilli
    June 1, 2022

    In alternative to the good answer of Stefan, an alternative is to use regexreplace on any non word character to _