Re: Regex to get last 3 digits of a number.

2009-11-24 Thread Philip Potter
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)

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread John W. Krahn
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

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread shadow52
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

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread shadow52
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

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread shadow52
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

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread shadow52
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

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread Alan Haggai Alavi
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

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread Shawn H Corey
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

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread Dave Tang
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

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread Yonghua Peng
--- 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 . >

Re: Regex to get last 3 digits of a number.

2009-11-24 Thread Dermot
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

Re: Regex to get last 3 digits of a number.

2009-11-23 Thread Dermot
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 >

Re: Regex to get last 3 digits of a number.

2009-11-23 Thread Dave Tang
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

Re: Regex to get last 3 digits of a number.

2009-11-23 Thread John W. Krahn
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

Re: Regex to get last 3 digits of a number.

2009-11-23 Thread Rob Coops
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

Re: Regex to get last 3 digits of a number.

2009-11-23 Thread Shawn H Corey
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