Solved

Substituting whitespace for +

Posted on 2002-03-27
2
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…

734 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