# perl regex substitution help



## graudeejs (Nov 17, 2009)

I want to convert all kinds of %xx, which you can get, when using URS, to normal characters.

For example %20 is space

I tried this:

```
$ARGV[0] =~ s/%([[:xdigit:]]{2})/\x{$1}/g;
```
But unfortunatly it is cousing compile time error.

Can anyone give me a hint how to do this?
I don't want to manually specify each possibility for %xx


I hope I was clear enough and this makes sence


----------



## SirDice (Nov 17, 2009)

```
sub decodeURL {
 $_ = shift;
 tr/+/ /;
 s/%(..)/pack('c', hex($1))/eg;
 return($_);
}
```

Found here :e


----------

