Solved

Convert string with two spaces to one space

Posted on 2002-06-03
3
165 Views
Last Modified: 2010-08-05
Hi,

Would like to convert the string. eg "Alexander  Master" to "Alexander Master".

Any idea ?
0
Comment
Question by:n_chai
3 Comments
 
LVL 4

Accepted Solution

by:
dda earned 50 total points
Comment Utility
my $s = "Alexander  Master";
print "was: [$s]\n";
$s =~ s/\s\s/ /g;
print "now: [$s]\n";
0
 
LVL 6

Expert Comment

by:andreif
Comment Utility
please, review your previous questions - you did not accept neither reject solutions
0
 
LVL 7

Expert Comment

by:yoren
Comment Utility
Try this to shrink blocks of whitespace into a single space:

my $s = "Alexander  Master   Jedi";
$s =~ s/\s+/ /g;
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now