# Substring replacement

**URL:** <https://discourse.julialang.org/t/substring-replacement/63794>\
**Category:** General Usage\
**Tags:** question, function\
**Created:** [June 30, 2021, 3:38am UTC](https://discourse.julialang.org/t/substring-replacement/63794 "2021-06-30T03:38:13Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [June 30, 2021, 4:31am UTC](https://discourse.julialang.org/t/substring-replacement/63794/4 "2021-06-30T04:31:27Z")

</div>

That’s the method for an array. You can’t do that in a string (and it turns out, making a vector of substitution pairs won’t help):

> [@Perform multiple replacements on a string in a single pass](https://discourse.julialang.org/t/perform-multiple-replacements-on-a-string-in-a-single-pass/43247):
>
> I have a couple of scripts which perform multiple replacements on the same string. It seems as though this can be sped up by searching for all potential matches. For example, something like julia\>replace("123",[r"1" =\> s"a",r"2" =\> s"b"]) "ab3" To be clear, that isn’t real output. Or maybe something with an or logic. Note that putting a . after replace outputs an array with each individual substitution. ie julia\> replace.("123",[r"1" =\> s"a",r"2" =\> s"b"]) 2-element Array{String,1}: "a23" "…

---

_[View the full topic](https://discourse.julialang.org/t/substring-replacement/63794)._
