# problem with string map and regex

**URL:** <https://community.f5.com/t/problem-with-string-map-and-regex/49463>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [April 5, 2013, 12:25pm UTC](https://community.f5.com/t/problem-with-string-map-and-regex/49463 "2013-04-05T12:25:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francois\_LAGANT](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@Francois\_LAGANT](https://community.f5.com/u/Francois_LAGANT)\
**Post date:** [April 5, 2013, 12:25pm UTC](https://community.f5.com/t/problem-with-string-map-and-regex/49463/1 "2013-04-05T12:25:53Z")

</div>

~~Hello,~~

~~I have a problem of syntax to write the string map operation with regex.~~

~~I am trying to delete a parameter~~~~ **toto=[0-9]&**~~

~~url:~~ [http://1.1.1.1/index.php?param=1&toto=5&tata=no~~](http://1.1.1.1/index.php?param=1&toto=5&tata=no~~)~~

~~I want the following result::~~ [http://1.1.1.1/index.php?param=1&tata=no~~](http://1.1.1.1/index.php?param=1&tata=no~~)~~

~~So I use:~~

HTTP::uri [string map {toto=[0-9]& “”} [HTTP::uri]]

~~But it doesn’t work~~

~~When i use this :~~

HTTP::uri [string map {toto=5& “”} [HTTP::uri]]

~~it works.~~

~~Could you help me please ?~~

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [April 5, 2013, 1:35pm UTC](https://community.f5.com/t/problem-with-string-map-and-regex/49463/2 "2013-04-05T13:35:44Z")

</div>

Here are two methods:

Method 1 (string map):

set uri [string tolower [HTTP::uri]]

set totonum [findstr $uri “toto=” 5 “&”]

set test “set newuri \[string map \{toto=$totonum& \”\“\} $uri\]”

eval $test

log local0. “newuri1: $newuri”

Method 2 (regsub):

if { [regsub -nocase “toto=\[0-9\]&” $uri “” newuri2] } {

log local0. “newuri2: $newuri2”

}
