Solved

Substituting whitespace for +

Posted on 2002-03-27
2
270 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:angelmoon
2 Comments
 
LVL 5

Expert Comment

by:Peewee
ID: 6899887
angelmoon,
is this what you want:

my $var = 'tie+tie';

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

regards
Peewee
0
 
LVL 5

Accepted Solution

by:
Sapa earned 100 total points
ID: 6899948
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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question