Sekhar-

i would suggest File::Basename

it has three functions, one of which returns the path to the file, in this 
case: /install/sql/

HTH
-Josh



sekhar kavuru <[EMAIL PROTECTED]> 
11/03/2005 11:59 AM

To
[email protected]
cc
$Bill Luebkert <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
Subject
RegExp help






my $str = "/install/sql/foo.c;
 
from $str string I need to get "/install/sql/ 
 
Any help

$Bill Luebkert <[EMAIL PROTECTED]> wrote:
[EMAIL PROTECTED] wrote:
> 
> how about we find your start and work forward? Brian did the end and 
work 
> backward, but i always like trying to find an alternative way to look at 

> things. i found it's normally easier for me.
> 
> if we know it will always have one or more / in front, but start exactly 

> at a / then what do we know about the string?
> 
> we know it will never have @@. ok. let's use .* a greedy way to get 
> everything up to what we want
> why? '.' matches everything.
> 
> then have / which is in front of what we want
> 
> then we know it's not @@ or in perl regexp: [EMAIL PROTECTED]@]
> ^ in that case means NOT, and the [] defines the region
> the \ in front of @ is for good measure.

[EMAIL PROTECTED]@] is the same as [EMAIL PROTECTED] and not exactly what 
you're looking for.

> and we don't care what's after, so we leave out an end definition
> 
> ----code-----
> #! /usr/bin/perl
> use strict;
> 
> my $str = "/install/sql/foo.c@@/main/integration/1"
> 
> my $item ='';
> 
> if($str =~ m/.*/([EMAIL PROTECTED]@])/)
> { $item = $1; }
> 
> print "$item\n";
> ----code-----
> 
> hope that helps you learn about reg exp,. peopel explaining things to me 

> by breaking it down is how i learned.
> (while i'm, by far, no master, it's nice to think i might be able to 
help 
> others progress to my point)

Did you test your code ?

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to