How to insert "\\" before multiple "_" in a string?

Hello!

Suppose I have:

str = "Hello_this_is_string"

How would I make it like this:

str_transform = "Hello\\_this\\_is\\_string"

In a programmatic way?

Kind regards

With the replace function:

julia> replace("Hello_this_is_string", "_" => "\\_")
"Hello\\_this\\_is\\_string"
5 Likes