# Replacing multiple strings errors

**URL:** <https://discourse.julialang.org/t/replacing-multiple-strings-errors/13654>\
**Category:** General Usage\
**Created:** [August 18, 2018, 8:48am UTC](https://discourse.julialang.org/t/replacing-multiple-strings-errors/13654 "2018-08-18T08:48:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [August 18, 2018, 9:37am UTC](https://discourse.julialang.org/t/replacing-multiple-strings-errors/13654/4 "2018-08-18T09:37:08Z")

</div>

I guess the design of `replace` for strings is to allow only one pattern because patterns in a string can overlap so it would be ambiguous in what sequence to apply them.  
But I have not implemented it so it is just a guess.

If you want to apply patterns sequentially you can do:

```
reduce(replace, ["A"=>"a", "B"=>"b", "C"=>"c"], init="ABC")

```

EDIT. Just to clarify what I mean by this ambiguity. The following codes do not produce identical results:

```julia
julia> reduce(replace, [1=>10, 10=>20], init=[1,2,3])
3-element Array{Int64,1}:
 20
  2
  3

julia> replace([1,2,3], 1=>10, 10=>20)
3-element Array{Int64,1}:
 10
  2
  3

```

because in `replace([1,2,3], 1=>10, 10=>20)` the patterns are not applied sequentially.

---

_[View the full topic](https://discourse.julialang.org/t/replacing-multiple-strings-errors/13654)._
