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

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: 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
Aah... I was so close. But slightly on the wrong track by using "split".. I had the regex as below. Now I just need to work out how to use this with my sort hash question. Thanks Pierre. In reply-to "Pierre Smolarek" <[EMAIL PROTECTED]> on Tue Jul 3 13:01:43 2001 >my $dateis = "2Jul2001"

RE: A Split Question

2001-07-03 Thread John Edwards
You do have delimiters there (of a sort) 2Jul2001 ^^ ^ Number Letter Number @dates = qw(2Jul2001 21Jul2001); foreach (@dates) { /(\d+)(\D+)(\d+)/; $day = $1; $month = $2; $year = $3; print "Day $day, month $month, year $year\n"; } John

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, 2001 12:24 PM Subject: A Split Questio