Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing 3 Spaces

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
0
0
GB
I want to replace 3 spaces with
Code:
null
?

Somehow, I thought it is good to use \s, but
Code:
$code             =~ s/'\s\s\s'/null/;
couldn't match three spaces in quotes??
Why is this?


Code:
$code             =~ s/'\s+'/null/;
could match 1+ space, but this is not the required behaviour :)
 
Code:
$code     =~ s/\'   \'/null/;

doesn't work, either :-(
 
'Must be something else going on...... this works for me all day long.
Code:
#!/usr/local/bin/perl
$str = "1'   '3'  '2";
print "$str\n";

$str =~ s/'\s\s\s'//;
print "$str\n";

That outputs
1' '3' '2
1 3' '2

Using Perl 5.6 on Solaris and ActivePerl 5.6 (build 613)

??

HTH


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top