How to replace ALL characters in string with asterisks

Hey all! I’m new to this forum (feedback on forum etiquette is appreciated, btw… b/c i have no clue) and I am also new to Elixir… well, programming in general… just for context.

How do I change ALL the characters in a string to asterisks? I need to be able to take in a string as an argument and then convert them (regardless of string length) to asterisks. I have tried String.replace but that is too specific, i need something more general to pattern match on something that is being obfuscated by the front-end against what i am sending up as a payload.
For instance, I send up a payload with “897789690” in a string and i want to validate that it obfuscates this in the front end with as many asterisks as there are characters in the string i sent up like “*********”

Hello and welcome…

Not the nicest, but it works.

iex> String.duplicate("*", String.length("koko"))

Ah! that is actually exactly what I needed. Thanks!

Welcome. You could also do

iex(53)> String.replace("test", ~r/./, "*")

EDIT: My mistake, you said you didn’t want to use String.replace


this still works though! thank you!