using a regex is may suitable.
$ perl -e '$x= a;b;c;d;e;f;g;h;@re=$x=~/(\w+;\w+);{0,1}/g;print @re'
a;b c;d e;f g;h
On 10/26/07, Mahurshi Akilla [EMAIL PROTECTED] wrote:
Is there an easy way (without writing our own proc) to split a string
based on number of occurances of a character ?
for
Is there an easy way (without writing our own proc) to split a string
based on number of occurances of a character ?
for example:
$my_string = a;b;c;d;e;f;g;h
@regsplitarray = split (/;/, $my_string) splits based on every 1
occurance of ;
what if i want it to do 2 at a time ? e.g.
On Oct 26, 3:51 am, [EMAIL PROTECTED] (Jeff Pang) wrote:
using a regex is may suitable.
$ perl -e '$x= a;b;c;d;e;f;g;h;@re=$x=~/(\w+;\w+);{0,1}/g;print @re'
a;b c;d e;f g;h
On 10/26/07, Mahurshi Akilla [EMAIL PROTECTED] wrote:
Is there an easy way (without writing our own proc) to split
@re = $x=~/(\w+;\w+);{0,1}/g;
Array @re holds the resulting matches (inside the brackets) of the
RegEx $x=~/(\w+;\w+);{0,1}/g
$x=~/(\w+;\w+);{0,1}/g
the /g means don't stop after one match.
/(\w+;\w+);{0,1}/
\w is a word
This matches one or more word(s) followed by a semicolon, again one or
more
On 10/26/07, yitzle [EMAIL PROTECTED] wrote:
@re = $x=~/(\w+;\w+);{0,1}/g;
Array @re holds the resulting matches (inside the brackets) of the
RegEx $x=~/(\w+;\w+);{0,1}/g
$x=~/(\w+;\w+);{0,1}/g
the /g means don't stop after one match.
/(\w+;\w+);{0,1}/
\w is a word
This matches one or
- Original Message -
From: Jeff Pang [EMAIL PROTECTED]
Newsgroups: perl.beginners
To: Mahurshi Akilla [EMAIL PROTECTED]
Cc: beginners@perl.org
Sent: Friday, October 26, 2007 6:51 AM
Subject: Re: split based on n number of occurances of a character
On 10/26/07, Mahurshi Akilla [EMAIL
Mahurshi Akilla wrote:
Is there an easy way (without writing our own proc) to split a string
based on number of occurances of a character ?
for example:
$my_string = a;b;c;d;e;f;g;h
@regsplitarray = split (/;/, $my_string) splits based on every 1
occurance of ;
what if i want it to do 2 at