2009/11/23 Alan Haggai Alavi :
> my $number = '0111';
> my ($index) = ( $number =~ /\d+(\d{3})/ );
>
> $index would contain the last three digits: '111'.
\d+ should be \d* above, otherwise you fail to match on 3 digit numbers:
p...@tui:~/tmp$ perl -E '
my $number = q{111};
my ($index)
Shawn H Corey wrote:
Yonghua Peng wrote:
--- On Tue, 24/11/09, Shawn H Corey wrote:
From: Shawn H Corey
Subject: Re: ç”å¤�: Regex to get last 3 digits of a number.
To: "gaochong"
Cc: "'John W. Krahn'" , "'Perl Beginners'"
Received: Tuesday, 24 November, 2009, 8:26 PM
gaochong wrote:
But
On Nov 23, 9:22 am, jwkr...@shaw.ca (John W. Krahn) wrote:
> shadow52 wrote:
> > Hey everyone,
>
> Hello,
>
> > I am trying to get just the last 3 numbers from the following number
> > from perl using regexs but I have not had no success so I was hoping
> > that I could get a little help on this. I
On Nov 23, 9:22 am, jwkr...@shaw.ca (John W. Krahn) wrote:
> shadow52 wrote:
> > Hey everyone,
>
> Hello,
>
> > I am trying to get just the last 3 numbers from the following number
> > from perl using regexs but I have not had no success so I was hoping
> > that I could get a little help on this. I
On Nov 23, 9:22 am, jwkr...@shaw.ca (John W. Krahn) wrote:
> shadow52 wrote:
> > Hey everyone,
>
> Hello,
>
> > I am trying to get just the last 3 numbers from the following number
> > from perl using regexs but I have not had no success so I was hoping
> > that I could get a little help on this. I
On Nov 23, 9:22 am, jwkr...@shaw.ca (John W. Krahn) wrote:
> shadow52 wrote:
> > Hey everyone,
>
> Hello,
>
> > I am trying to get just the last 3 numbers from the following number
> > from perl using regexs but I have not had no success so I was hoping
> > that I could get a little help on this. I
Hi,
The following should work:
my $number = '0111';
my ($index) = ( $number =~ /\d+(\d{3})/ );
$index would contain the last three digits: '111'.
To learn about regular expressions in Perl, you can go through `perldoc
perlre` and `perldoc perlretut`. The Perldoc website
(http://pe
Yonghua Peng wrote:
>
> --- On Tue, 24/11/09, Shawn H Corey wrote:
>
>> From: Shawn H Corey
>> Subject: Re: 答复: Regex to get last 3 digits of a number.
>> To: "gaochong"
>> Cc: "'John W. Krahn'" , "'Perl Beginners'"
>>
>> Received: Tuesday, 24 November, 2009, 8:26 PM
>> gaochong wrote:
>>> B
On Tue, 24 Nov 2009 18:33:30 +1000, Dermot wrote:
2009/11/23 Dave Tang :
On Tue, 24 Nov 2009 09:39:09 +1000, Dermot
wrote:
2009/11/23 Dave Tang :
On Mon, 23 Nov 2009 23:14:51 +1000, Shawn H Corey
Hi Shawn et al.,
I am also intrigued by the \z anchor. I had a look at perldoc
perl
--- On Tue, 24/11/09, Shawn H Corey wrote:
> From: Shawn H Corey
> Subject: Re: 答复: Regex to get last 3 digits of a number.
> To: "gaochong"
> Cc: "'John W. Krahn'" , "'Perl Beginners'"
>
> Received: Tuesday, 24 November, 2009, 8:26 PM
> gaochong wrote:
> > But I think substr is better .
>
2009/11/23 Dave Tang :
> On Tue, 24 Nov 2009 09:39:09 +1000, Dermot wrote:
>
>> 2009/11/23 Dave Tang :
>>>
>>> On Mon, 23 Nov 2009 23:14:51 +1000, Shawn H Corey
>>>
>>> Hi Shawn et al.,
>>>
>>> I am also intrigued by the \z anchor. I had a look at perldoc perlreref
>>> and
>>> found
>>>
>>> \z M
2009/11/23 Dave Tang :
> On Mon, 23 Nov 2009 23:14:51 +1000, Shawn H Corey
>
> Hi Shawn et al.,
>
> I am also intrigued by the \z anchor. I had a look at perldoc perlreref and
> found
>
> \z Match absolute string end
>
> My question is what is the difference between \z and $? And when should I
>
On Mon, 23 Nov 2009 23:14:51 +1000, Shawn H Corey
wrote:
shadow52 wrote:
[snip]
The number is 0111
I was just wanting to get the last 3 digits from this number to be
able to get an exact word phrase from my already loaded Hash table
that I have created for various numbers tha
shadow52 wrote:
Hey everyone,
Hello,
I am trying to get just the last 3 numbers from the following number
from perl using regexs but I have not had no success so I was hoping
that I could get a little help on this. I just ordered the regex book
from oreilly so that hopefully in the future I w
On Mon, Nov 23, 2009 at 4:27 AM, shadow52 wrote:
> Hey everyone,
>
> I am trying to get just the last 3 numbers from the following number
> from perl using regexs but I have not had no success so I was hoping
> that I could get a little help on this. I just ordered the regex book
> from oreilly s
shadow52 wrote:
> Hey everyone,
>
> I am trying to get just the last 3 numbers from the following number
> from perl using regexs but I have not had no success so I was hoping
> that I could get a little help on this. I just ordered the regex book
> from oreilly so that hopefully in the future I w
16 matches
Mail list logo