# String Replace Multiple | Codeblock

**URL:** <https://forum.dynamobim.com/t/string-replace-multiple-codeblock/48577>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [March 28, 2020, 5:00pm UTC](https://forum.dynamobim.com/t/string-replace-multiple-codeblock/48577 "2020-03-28T17:00:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zalgirietis.minde](https://avatars.discourse-cdn.com/v4/letter/z/dbc845/32.png) [@zalgirietis.minde](https://forum.dynamobim.com/u/zalgirietis.minde)\
**Post date:** [March 28, 2020, 5:00pm UTC](https://forum.dynamobim.com/t/string-replace-multiple-codeblock/48577/1 "2020-03-28T17:00:33Z")

</div>

Hi,

I’m trying to make this script work properly. It’s only replacing the string with a very first string item. See pic.  
Not sure where the problem is. Maybe levels or lacing? Anything helps.

 ![2020-03-28 08_59_17-Dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/b/abec3e624c537ec2aabe924571ee15d82ef74e20.png)

```
str;
search;
replace;
n = DSCore.List.Count(search);
c = [Imperative]{
	i=0;
	result = str;
	while(i<n){
		result = String.Replace(result,search[i],replace[i]);
		i = i+1;
	}
	return = result;
};
```

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [March 28, 2020, 5:50pm UTC](https://forum.dynamobim.com/t/string-replace-multiple-codeblock/48577/2 "2020-03-28T17:50:03Z")

</div>

Hi @zalgirietis.minde

Add List.Cycle along with List.Count and you should be good:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/5/755c4135ff8900498913b57ad0a1753564c923c8.png)

---

<div class="post-metadata">

**Author:** ![zalgirietis.minde](https://avatars.discourse-cdn.com/v4/letter/z/dbc845/32.png) [@zalgirietis.minde](https://forum.dynamobim.com/u/zalgirietis.minde)\
**Post date:** [March 28, 2020, 10:02pm UTC](https://forum.dynamobim.com/t/string-replace-multiple-codeblock/48577/3 "2020-03-28T22:02:43Z")

</div>

Thanks! Exactly as I wanted!
