# Delete a substring

**URL:** <https://community.f5.com/t/delete-a-substring/60601>\
**Category:** Technical Forums\
**Tags:** irules, ltm, application-delivery\
**Created:** [May 15, 2017, 11:17am UTC](https://community.f5.com/t/delete-a-substring/60601 "2017-05-15T11:17:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bc1](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bc1](https://community.f5.com/u/bc1)\
**Post date:** [May 15, 2017, 11:17am UTC](https://community.f5.com/t/delete-a-substring/60601/1 "2017-05-15T11:17:03Z")

</div>

Hi,

I need to delete a substring from [HTTP::payload] before I pass it on for load-balancing but am running into problems with the error "char map list unbalanced ..

I need to strip two strings out completely and have tried using “string map” and “string replace” - this works fine when substituting for another string but not when substituting an empty string or tab / newline character ..

Surely there must be a simple way to do this ?!

Thanks!

e.g. the following works fine for “xyz” but fails for “”

```tcl
set strSubstitute ""
set strSubstitute "xyz"
set strHTTPPayload [HTTP::payload]
set strHTTPPayload [string map -nocase "$strOne $strSubstitute" $strHTTPPayload]
set strHTTPPayload [string map -nocase "$strTwo $strSubstitute" $strHTTPPayload]

```

---

<div class="post-metadata">

**Author:** ![Niels\_van\_Sluis](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/niels_van_sluis/32/3759_2.png) [@Niels\_van\_Sluis](https://community.f5.com/u/Niels_van_Sluis)\
**Post date:** [May 15, 2017, 11:28am UTC](https://community.f5.com/t/delete-a-substring/60601/2 "2017-05-15T11:28:01Z")

</div>

I’ve used this syntax before to remove spaces (%20) from URIs. Maybe you could use curly brackets instead of double quotes.

```tcl
set new_uri [string map {"%20" ""} $uri]

```
