in reply to help on reg ex

I'm not really clear on what you're asking for with extracting /great and putting it back. Both the inital and resulting $a's in your question look the same to me.

Here's what I came up with...

my $a = '/export/home/test/great'; $a =~ / (.*) (\/[^\/]*) /x; my $front = $1; my $back = $2; print "a: $a\n"; print "front: $front\n"; print "back: $back\n";

Note: I'm using /x to add some whitespace to the regex for clarity. You can ignore the spaces.

That returns...

a: /export/home/test/great front: /export/home/test back: /great

I think the other solutions are affected by regex greed. So they'll pull out the longest string starting with a slash. If I'm oversimplifying things, then I'm sorry.

I hope this helps.

Replies are listed 'Best First'.
Re: Re: help on reg ex
by Anonymous Monk on May 20, 2003 at 15:55 UTC
    I must have forgotten to thank you , thanks for helping me out