develooper Front page | perl.macperl.anyperl | Postings from August 2003

Re: [MacPerl-AnyPerl] Spliting a string

Thread Previous
From:
John Delacour
Date:
August 18, 2003 13:43
Subject:
Re: [MacPerl-AnyPerl] Spliting a string
Message ID:
p06001d07bb66ea937e95@[10.0.0.4]
At 10:04 pm +0200 18/8/03, Eelco Alosery wrote:
>I want to split a string into servral partsThe string starts whith 
>## than the text and than again ## but the string lent is not a 
>fixed sise.
>It can by:
>##text1##text2##text3##
>but also longer like:
>##text1##text2##text3##text4##text5##text6##text7##
>
>I want to split this string zo i can display the text each on a 
>seperat line or eddit the text


Just use split:

#!/usr/bin/perl
$s = qq~##text1##text22##text333##text4444##text5555~;
@parts = split qq~##~, $s ;
for (@parts) {
     print qq~$_$/~ if /./ ;
}

Thread Previous


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