Substituting whitespace for +

Hi,
I am trying to replace all the + in a string for whitespace. But I can't seem to be able to find the + in the string.
Any ideas?

Thanks,
Angelmoon
angelmoonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SapaConnect With a Mentor Commented:
angelmoon,

it looks like you attempts to decode URL-encoded string.
Such strings can also contain %NN escape codes, which
represents characters with hexadecimal code NN. For example:
* is %2a, / is %2f etc.

There are at least 3 ways to decode such strings:

1. using URI::Escape module

use URI::Escape;
$decoded = uri_unescape($encoded);

2. using CGI module

use CGI;

$decoded = CGI::unescape($encoded);

3. Do it manually :(

$encoded =~ tr/+/ /;
$encoded =~ s/%([0-9a-fA-F]{2})/chr hex($1)/ge;

0
 
PeeweeCommented:
angelmoon,
is this what you want:

my $var = 'tie+tie';

$var =~ s/\+/ /ig;
print "var:$var\n";

regards
Peewee
0
All Courses

From novice to tech pro — start learning today.