Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting a string with multiple white spaces with perl?

Tags:

regex

split

perl

I am trying to split a string with multiple white spaces. I only want to split where there are 2 or more white spaces. I have tried multiple things and I keep getting the same output which is that it splits after every letter. Here is the last thing I tried

@cellMessage = split(s/ {2,}//g, $message);
                foreach(@cellMessage){
                    print "$_ \n";
                }
like image 761
shinjuo Avatar asked Jul 29 '10 20:07

shinjuo


1 Answers

@cellMessage = split(/ {2,}/, $message);
like image 66
Erik Avatar answered Nov 15 '22 08:11

Erik