For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Fwd: reg expression again









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Fwd: reg expression again
Anshul Saxena

2006-10-23, 6:57 pm

---------- Forwarded message ----------
From: Anshul Saxena <anshulacxiom@gmail.com>
Date: Oct 23, 2006 8:38 AM
Subject: Re: reg expression again
To: chen li <chen_li3@yahoo.com>

You should try :
my $file_name =~ /^(OT).*(\d+$)/

The caret ^ when outside any brackets, indicates that the character you are
trying to match should be at the beginning.
I hope this works. Lemme know if it doesn't.

Regards

On 10/22/06, chen li <chen_li3@yahoo.com> wrote:
>
> Hi all,
>
> I write a small script as follows:
>
> use strict;
> use warnings;
>
> my $file_name='OT-q1.001';
>
> if ($file_name=~/(OT)*.(\d+$)/){
> print "find it\t $file_name";
> }else {print "No math";}
>
> The problem is that it also macth the following
> string:
>
> my $file_name='I:/Common/Notebooks/Trans10C.032';
> (ot in the Notebook)
>
> Any help will be appreciated.
>
> Li
>
>
> ________________________________________
__________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> < http://learn.perl.org/first-response>
>
>
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com