# Remove whitespaces from $args

**URL:** <https://www.ruby-forum.com/t/remove-whitespaces-from-args/244534>\
**Category:** NGINX\
**Created:** [April 28, 2016, 12:46pm UTC](https://www.ruby-forum.com/t/remove-whitespaces-from-args/244534 "2016-04-28T12:46:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [April 28, 2016, 12:46pm UTC](https://www.ruby-forum.com/t/remove-whitespaces-from-args/244534/1 "2016-04-28T12:46:31Z")

</div>

Hi,  
Tell me please, how can I remove all spaces from $args ?

I create solution, it remove up to 5 spaces. But it not best way i  
think.

```
        if ($args ~ (.*)\s(.*)$) { set $args $1$2; }
        if ($args ~ (.*)\s(.*)$) { set $args $1$2; }
        if ($args ~ (.*)\s(.*)$) { set $args $1$2; }
        if ($args ~ (.*)\s(.*)$) { set $args $1$2; }
        if ($args ~ (.*)\s(.*)$) { set $args $1; }

```

Posted at Nginx Forum:

> **[Remove whitespaces from $args](https://forum.nginx.org/read.php?2,266482,266482#msg-266482)**
>
> Hi, Tell me please, how can I remove all spaces from $args ? I create solution, it remove up to 5 spaces. But it not best way i think. if ($args ~ (.\*)\\s(.\*)$) { set $args $1$2; } if ($args ~ (.\*)\\s(.\*)$) { set $args $1$2; }

---

<div class="post-metadata">

**Author:** ![Hett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ee59a6/32.png) [@Hett](https://www.ruby-forum.com/u/Hett)\
**Post date:** [April 28, 2016, 7:17pm UTC](https://www.ruby-forum.com/t/remove-whitespaces-from-args/244534/2 "2016-04-28T19:17:54Z")

</div>

On Thu, Apr 28, 2016 at 06:46:11AM -0400, Hett wrote:

Hi there,

> Tell me please, how can I remove all spaces from $args ?

I suspect that you may need to use one of the programming language  
modules available in your nginx to do that.

Why do you want to do it?

Perhaps there is an alternative acceptable way to achieve your final  
desired result.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Hett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ee59a6/32.png) [@Hett](https://www.ruby-forum.com/u/Hett)\
**Post date:** [April 29, 2016, 8:17am UTC](https://www.ruby-forum.com/t/remove-whitespaces-from-args/244534/3 "2016-04-29T08:17:45Z")

</div>

Hi,  
I using third-party software,  
in some cases users create not valid url, and I want to fix it  
for example:  
[http://xx.yy/xx/yy/?a=1&b=1](http://xx.yy/xx/yy/?a=1&b=1) 2 3.txt  
need replace by:  
[http://xx.yy/xx/yy/?a=1&b=123.txt](http://xx.yy/xx/yy/?a=1&b=123.txt)

Posted at Nginx Forum:

> **[Re: Remove whitespaces from $args](https://forum.nginx.org/read.php?2,266482,266511#msg-266511)**
>
> Hi, Tell me please, how can I remove all spaces from $args ? I create solution, it remove up to 5 spaces. But it not best way i think. if ($args ~ (.\*)\\s(.\*)$) { set $args $1$2; } if ($args ~ (.\*)\\s(.\*)$) { set $args $1$2; }
