I did read them all. I think Brian Raven's subroutine you can place in a 
package is one of the better ideas, but something I like to do i did not 
see done, So i would like to chime in, in the hopes that I can help in 
teaching some regexp here.

---------quoted----------
From: sekhar kavuru <[EMAIL PROTECTED]>
I need a REGEX to get a string between two characters from a static string 


e.g. 

I need to get foo.c , i.e string between / and  @@ 

First it needs find where @@ occurs in the string and trace back to file 
name until it encounters / character.
---------quoted----------

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.

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)

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

Reply via email to