Re: a split(); question

2003-01-21 Thread R. Joseph Newton
justino berrun wrote: > #hello, is there a way to split a string between a digit and character > $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would make three new >strings Try: (my $ElementString = $string) =~ s /(\d+)(\D+)/$1-$2/g; print "$ElementString\n"; $ElementString is th

Re: a split(); question

2003-01-21 Thread John W. Krahn
Rob Dixon wrote: > > Justino Berrun wrote: > > #hello, is there a way to split a string between a digit and character > > #without losing the digit or the character > > #Any help would be very appreciated > > > > $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would > > make three new

Re: a split(); question

2003-01-21 Thread Rob Dixon
Justino Berrun wrote: > #hello, is there a way to split a string between a digit and character > #without losing the digit or the character > #Any help would be very appreciated > > $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would > make three new strings > > @newstrings=split(/(\

RE: a split(); question

2003-01-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
justino berrun wrote: > #hello, is there a way to split a string between a digit and character > #without losing the digit or the character > #Any help would be very appreciated > > $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would > make three new strings > > @newstrings=split(

Re: a split(); question

2003-01-21 Thread Janek Schleicher
On Wed, 22 Jan 2003 02:46:27 +0800, Justino Berrun wrote: > #hello, is there a way to split a string between a digit and character > #without losing the digit or the character > #Any help would be very appreciated > > $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would make three

a split(); question

2003-01-21 Thread justino berrun
#hello, is there a way to split a string between a digit and character #without losing the digit or the character #Any help would be very appreciated $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would make three new strings @newstrings=split(/(\d)([a-zA-Z])/,$string);

Re[4]: A Split Question

2001-07-03 Thread Maxim Berlin
Hello Brett, Tuesday, July 03, 2001, Brett W. McCoy <[EMAIL PROTECTED]> wrote: >> >> > > > Unpack works well with fixed format data like this. >> >> > > >> >> > > Why would you use unpack when this can be easily split apart with a regex? >> >> > > I'd think unpack would be overkill! >> >> >> >>

Re: Re[2]: A Split Question

2001-07-03 Thread Luke Bakken
> > >> > > > Unpack works well with fixed format data like this. NB: *fixed format* - i.e. unchanging throughout the data. > the flexibility of a regular expression. If the date style changes to, > say, 02July01 (instead of 2July2001), the regula

Re: Re[2]: A Split Question

2001-07-03 Thread Jeff 'japhy' Pinyan
On Jul 3, Maxim Berlin said: > my ($month, $day, $year) = /(\d+)(\D+)(\d+)/; I'd be evil and do: my ($mon, $day, $yr) = split /(\D+)/; Now *that* is quite nice, in my opinion. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ I am Marillion, the wielder of Rin

Re: Re[2]: A Split Question

2001-07-03 Thread Brett W. McCoy
On Tue, 3 Jul 2001, Maxim Berlin wrote: > Tuesday, July 03, 2001, Brett W. McCoy <[EMAIL PROTECTED]> wrote: > > >> > > > Unpack works well with fixed format data like this. > >> > > > >> > > Why would you use unpack when this can be easily split apart with a regex? > >> > > I'd think unpack would

Re: A Split Question

2001-07-03 Thread Jos Boumans
on a side note, if you CAN use perls internal char classes you really want to do that firstly to avoid typos, secondly, they're much faster. and if you're using the same regexp over and over again, you *might* want to concider building it outside the loop with the /o switch (this all performace b

Re[2]: A Split Question

2001-07-03 Thread Maxim Berlin
Hello Brett, Tuesday, July 03, 2001, Brett W. McCoy <[EMAIL PROTECTED]> wrote: >> > > > Unpack works well with fixed format data like this. >> > > >> > > Why would you use unpack when this can be easily split apart with a regex? >> > > I'd think unpack would be overkill! >> >> why is it overkill

Re: A Split Question

2001-07-03 Thread Brett W. McCoy
On Tue, 3 Jul 2001, Luke Bakken wrote: > > > > Unpack works well with fixed format data like this. > > > > > > Why would you use unpack when this can be easily split apart with a regex? > > > I'd think unpack would be overkill! > > why is it overkill any more that a regex? Are you saying we shou

Re: A Split Question

2001-07-03 Thread Pierre Smolarek
$year) = $dateis =~ /([0-9]+)([A-Za-z]+)([0-9]+)/; > > It makes me sleeper at night > > > - Original Message - > From: "John Edwards" <[EMAIL PROTECTED]> > To: "'Will Crain'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> >

Re: A Split Question

2001-07-03 Thread Pierre Smolarek
--- From: "John Edwards" <[EMAIL PROTECTED]> To: "'Will Crain'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, July 03, 2001 3:54 PM Subject: RE: A Split Question > Sorry to pick holes in your first post to the list ;) but this part of y

RE: A Split Question

2001-07-03 Thread John Edwards
01 15:41 To: [EMAIL PROTECTED] Subject: RE: A Split Question -- Original Message -- >My file has dates in it that either come out as "2Jul2001" or "21Jul2001". > So one or two digits for the day, three for the month, and four for the >year. > >So I would like t

RE: A Split Question

2001-07-03 Thread Will Crain
-- Original Message -- >My file has dates in it that either come out as "2Jul2001" or "21Jul2001". > So one or two digits for the day, three for the month, and four for the >year. > >So I would like to split out the day, month, year, and am interested in >splitting techniques, where there are n

Re: A Split Question

2001-07-03 Thread Luke Bakken
> > Unpack works well with fixed format data like this. > > Why would you use unpack when this can be easily split apart with a regex? > I'd think unpack would be overkill! > > -- Brett if you had thousands of dates to split up, unpack is much faster than regexes. way way faster. Luke

Re: A Split Question

2001-07-03 Thread Brett W. McCoy
On Tue, 3 Jul 2001, Luke Bakken wrote: > my @dates = qw(2Jul2001 21Jul2001); > > for my $date (@dates) > { > my ($month, $day, $year) = > length $date == 8 ? > unpack 'AA3A4', $date : > unpack 'A2A3A4', $date; > >

Re: A Split Question

2001-07-03 Thread Luke Bakken
my @dates = qw(2Jul2001 21Jul2001); for my $date (@dates) { my ($month, $day, $year) = length $date == 8 ? unpack 'AA3A4', $date : unpack 'A2A3A4', $date; print "M: ", $month, "\tD: ", $day, "\tY: ",

RE: Re: A Split Question

2001-07-03 Thread paul
01 >my $dateis = "2Jul2001"; >my ($date,$month,$year) = $dateis =~ /([0-9]+)([A-Za-z]+)([0-9]+)/; > >print "$date - $month - $year \n"; > >:) > >with regards, > >Pierre > >- Original Message - >From: <[EMAIL PROTECTED]>

RE: A Split Question

2001-07-03 Thread John Edwards
ear\n"; } John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 03 July 2001 12:24 To: [EMAIL PROTECTED] Subject: A Split Question Hi. My file has dates in it that either come out as "2Jul2001" or "21Jul2001". So one or two digits for the day,

Re: A Split Question

2001-07-03 Thread Pierre Smolarek
my $dateis = "2Jul2001"; my ($date,$month,$year) = $dateis =~ /([0-9]+)([A-Za-z]+)([0-9]+)/; print "$date - $month - $year \n"; :) with regards, Pierre - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, July 03

A Split Question

2001-07-03 Thread paul
Hi. My file has dates in it that either come out as "2Jul2001" or "21Jul2001". So one or two digits for the day, three for the month, and four for the year. So I would like to split out the day, month, year, and am interested in splitting techniques, where there are no delimeters. Of course