On Wed, Aug 06, 2003 at 07:02:21PM -0700 Gupta, Sharad wrote:

> I have a path like:
> 
> $s = "http::/foo/bar:http::/foo1/bar1:http/foo1/bar1";
> 
> I am trying to get all the http paths which are seperated by ":" like this:
> 
> @x = ($s =~ /(http::.*?):(?=http::.*?)/g)
> 
> The problem is i get all the elements in @x except the last one.

Better use split with a negative look-ahead and -behind assertion:

    $_ = "http::/foo/bar:http::/foo1/bar1:http/foo1/bar1";
    @a = split /(?<!:):(?!:)/, $_;
    print join "\n", @a;
    __END__
    http::/foo/bar
    http::/foo1/bar1
    http/foo1/bar1
    
So only split on ':' when it's neither preceeded nor followed by another
':'.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to