> -----Original Message-----
> From: Stewart Anderson
> Sent: 18 November 2008 12:20
> To: beginners@perl.org
> Cc: Stewart Anderson
> Subject: RE: Regular expression problem
> 
> > -----Original Message-----
> > From: howa [mailto:[EMAIL PROTECTED]
> > Sent: 18 November 2008 08:53
> > To: beginners@perl.org
> > Subject: Regular expression problem
> >
> > Hello,
> >
> > I have two strings:
> >
> > 1. abc
> > 2. abc&
> >
> >
> > The line of string might end with "&" or not, so I use the
expression:
> >
> > (.*)[$&]
> >
> >
> > Why it didn't work out?
> >
> >
> > Thanks.
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > http://learn.perl.org/
> >
> Don't think there is anything wrong with the  regex per say  the
script
> below uses  ur regex and seems to work  ok,  in that it matches lines
with
> an &  anchored to the end of the line.
> 
> HTH
> 
> #! /usr/bin/perl
> use warnings;
> use strict;
> while (<DATA>){
>               print "String:\t" . $_   ;
>     if ( $_  =~ /(.*)[&]$/) {
>         print "match in line: $.\n";
>     }else {
>         print "no match in line: $.\n";
> 
>     }
> 
> }
> __DATA__
>  123&
>  &123
> 123456&
> 12&4545

lol

Oops  I did not realise that I  actually changed  your regex slightly!! 



Information in this email including any attachments may be privileged, 
confidential and is intended exclusively for the addressee. The views expressed 
may not be official policy, but the personal views of the originator. If you 
have received it in error, please notify the sender by return e-mail and delete 
it from your system. You should not reproduce, distribute, store, retransmit, 
use or disclose its contents to anyone. Please note we reserve the right to 
monitor all e-mail communication through our internal and external networks. 
SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and 
are used under licence. British Sky Broadcasting Limited (Registration No. 
2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home 
Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited 
(Registration No. 2340150) are direct or indirect subsidiaries of British Sky 
Broadcasting Group plc (Registration No. 2247735). All of the companies 
mentioned in this paragraph are incorporated in England and Wales and share the 
same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to