In a message dated 12/11/2002 12:27:41 PM Pacific Standard Time, 
[EMAIL PROTECTED] writes:


> > If it's on the front, it won't remove it because it doesn't have a
> preceeding
> > / in that case.
> 
> 'm confused...according to your first post:

I apologize for the confusion, that was in response to Frank's suggestion 
that didn't have the leading '/' question-marked.

> >$list =~ s|$name||; # remove $name from the list if it's in the list
> >$list =~ s|//|/|; # if $name was in the middle of the list, it would have
> >left behind two /s, remove one
> >$list =~ s|^/||; # if $name was at the front of the list, remove the
> leading /
> >$list =~ s|/$||; # if $name was at the end of the list, remove the trailing
> /
> 
> By rule 3 you should have a preceeding / and by rule 4 you should have an
> ending /
> Therefore, your list should always look like:
> /x/y/z/
> 
> Is this not the case?
> 
> 
Here's an example:
$list = "A.Jones/S.Smith/M.Anderson";
$name = "M.Anderson"; # or "A.Jones" or "S.Smith"

With the M.Anderson, it should leave $list as:
"A.Jones/S.Smith"

My first command above would remove the name and leave the list as one of:
"/S.Smith/M.Anderson"
"A.Jones//M.Anderson"
"A.Jones/S.Smith/"

And I needed the three more commands to clean up the list, one for each of 
those cases.


Your suggestion of:
$list =~ s|((?!.)/)?\b$name\b/?||;

Works in all cases except for the last name in the list, where it leaves the 
/ that was before the last name as a trailing / on list, and requires (like 
Frank's $list =~ s|/?$name||;) a second substitution to clean up the / in 
that special case.

Hope this clarifys things for you/everyone.

                               /\/\ark

Reply via email to