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
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
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(/(\
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(
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
#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);
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!
>> >>
>> >>
> > >> > > > 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
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
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
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
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
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
$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]>
>
---
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
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
-- 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
> > 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
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;
>
>
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: ",
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]>
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,
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
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
24 matches
Mail list logo