
winfinit
User
May 15, 2008, 10:46 PM
Post #2 of 3
(1471 views)
|
|
Re: [perl001] Searching a string until a certain substring is found
[In reply to]
|
Can't Post
|
|
you can remove all characters that are longer then 3 letters winfinit:~ winfinit$ cat 1 my $test = "THIS IS A TEST STRING"; $test =~ s/\w{4,}//ig; print $test . "\n"; winfinit:~ winfinit$ perl 1 IS A so now you removed all those words, you can do split on a result on a space, and drop all results into an array, like this: winfinit:~ winfinit$ cat 1 my $test = "THIS IS A TEST STRING"; $test =~ s/\w{4,}//ig; my @array = split(' ',$test); foreach(@array){print "$_\n";} winfinit:~ winfinit$ perl 1 IS A hope that helps
|