my $str = "/install/sql/foo.c;
from $str string I need to get "/install/sql/
Any help
$Bill Luebkert <[EMAIL PROTECTED]> wrote:
$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 protecti!
on around
http://mail.yahoo.com
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
