# Perform multiple replacements on a string in a single pass

**URL:** https://discourse.julialang.org/t/perform-multiple-replacements-on-a-string-in-a-single-pass/43247
**Category:** Performance
**Tags:** strings, regex
**Created:** [July 17, 2020, 4:22pm UTC](https://discourse.julialang.org/t/perform-multiple-replacements-on-a-string-in-a-single-pass/43247 "2020-07-17T16:22:12Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![nstgc](https://avatars.discourse-cdn.com/v4/letter/n/e0b2c6/32.png) [@nstgc](https://discourse.julialang.org/u/nstgc)
#### Post date: [July 17, 2020, 6:10pm UTC](https://discourse.julialang.org/t/perform-multiple-replacements-on-a-string-in-a-single-pass/43247/9 "2020-07-17T18:10:33Z")

</div>

> [@tbeason](#):
>
> `replace("123",[r"1" => s"a", r"a2" => s"12"])`

That returns an error.

@stevengj

Some of the regex expressions are convoluted and exceed 80 characters and I’m matching things ranging from single characters to about ten and I’m subbing them with strings ranging from 5 to 20 characters. I’m not sure if that is the sort of range you’re talking about, but I’ll see how it works in my main problem and report back.

Thanks for the clarification.

Also, if I may, where might I go to unravel what your suggestion actually does? I tried `@less` but that just took me to the definition of `replace`. This is a bit beyond me and I’d like to use this as a learning experience as well as a practical answer if possible.

---

_[View the full topic](https://discourse.julialang.org/t/perform-multiple-replacements-on-a-string-in-a-single-pass/43247)._
