develooper Front page | perl.beginners | Postings from July 2010

usage of Split on pattern matching

Thread Next
From:
Chandan Kumar
Date:
July 19, 2010 05:41
Subject:
usage of Split on pattern matching
Message ID:
839597.75875.qm@web95616.mail.in.yahoo.com
Hi all,
 
Iam beginner to perl & i have a small query on split.
using split i want print everything even the character used to split on string.
 
Here is my example :
 
my $string = "hi123now456itstimeforsplit789right"
my @array  = split ( '/(\d+\s)/ ',$string); 
## Trying to split using digitnumber followed by space
 
print "@array \n";
 
please explain if anything wrong with my syntax.
 
My assumption is in the given string as there is no space followed by digits the output of array should be empty.
 
When I run the program ,it prints the whole string. so my assumption is wrong.
 
please Could some one explain me on this?
 
 
Best Regards,
chandan.
 
 



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About