What is wrong with this substitution?

Posted by user352860 on Stack Overflow See other posts from Stack Overflow or by user352860
Published on 2010-06-02T12:27:13Z Indexed on 2010/06/02 12:54 UTC
Read the original article Hit count: 158

Filed under:
|
|
#!/usr/bin/perl

use strict;
use warnings;

my $s = "sad day
 Good day
 May be Bad Day 
 ";

$s =~ s/\w+ \w+/_/gm;

print $s;

I am trying to substitute all spaces between words with _, but it is not working. What is wrong with that?

© Stack Overflow or respective owner

Related posts about regex

Related posts about perl