Replace space

Posted on 1999-11-10
Medium Priority
Last Modified: 2012-05-04
I have a perl-script that resives input from a html-doc.(via POST) (It resives text) The text are words. And I wanna
convert the text that I get from html like this: Hello, this is a test
to hello,+this+is+a+test
Is that possible?

Question by:govinje
  • 2
  • 2
LVL 85

Accepted Solution

ozo earned 400 total points
ID: 2196433
($text=lc $text) =~ tr/ /+/;

Author Comment

ID: 2196497
But we could write it like this also.. :)
$text =~ s/\ /+/g;
LVL 85

Expert Comment

ID: 2196535
$text =~ s/ /+/g;
except that it won't convert Hello to hello
But if you knew that, what was the question for?
And if you
use CGI;
to get the text, it takes care of converting + for you, as well as %20 %2b etc

Author Comment

ID: 2198655
Oh.. I found out later..
Right after I have posted the quiz...

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans

600 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