[EMAIL PROTECTED] wrote:
>
> I have a list of names, separated by the '/' character in a variable, $list,
> and a name in the variable $name. If the name appears in the list, I want to
> remove it and clean up $list. It takes me 4 calls to s///, and it looks
> clunky. I have a feeling that some
Hi, Mark, :)
On Wed, 11 Dec 2002 [EMAIL PROTECTED] wrote:
> I have a list of names, separated by the '/' character in a
> variable, $list, and a name in the variable $name. If the name
> appears in the list, I want to remove it and clean up $list. It
> takes me 4 calls to s///, and it looks clu
> I apologize for the confusion, that was in response to Frank's suggestion
> that didn't have the leading '/' question-marked.
Sorry...I misunderstood your OP...here is a solution that should work
$list =~ s!(/)?\b$name\b(/)?!$2 ? ($1||'') : ($2||'')!e;
Tanton
--
To unsubscribe, e-mail: [EM
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
> If it's on the front, it won't remove it because it doesn't have a
preceeding
> / in that case.
I'm confused...according to your first post:
>$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 beh
In a message dated 12/11/2002 12:00:43 PM Pacific Standard Time,
[EMAIL PROTECTED] writes:
> How about this:
>
> $list =~ s|/$name||;
> $list =~ s|^/||;
>
> If it's at the end, it will remove the last /.
> If it's in the middle it will fill in correctly.
> If it's
;[EMAIL PROTECTED]>
> Sent: Wednesday, December 11, 2002 3:06 PM
> Subject: Re: Removing a name from a list - advanced regexp - TIMTOWTDI
>
>
> > > In a message dated 12/11/2002 11:54:48 AM Pacific Standard Time,
> > > [EMAIL PROTECTED] writes:
> > >
&g
Forget that...this works in all cases:
$list =~ s|((?!.)/)\b$name\b/?||;
- Original Message -
From: "Tanton Gibbs" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, December 11, 2002 3:06 PM
Subject: Re: Removing a name f
> In a message dated 12/11/2002 11:54:48 AM Pacific Standard Time,
> [EMAIL PROTECTED] writes:
>
>
> > What about just
> > $list =~ s|/?$name/?||
>
> If $name appears in the middle of the list, this removes both '/'
characters.
> This was my first guess as well.
Ah, didn't think about that one :)
In a message dated 12/11/2002 11:54:48 AM Pacific Standard Time,
[EMAIL PROTECTED] writes:
> What about just
> $list =~ s|/?$name/?||
If $name appears in the middle of the list, this removes both '/' characters.
This was my first guess as well.
> But you should be careful about that in case
.--[ [EMAIL PROTECTED] wrote (2002/12/11 at 14:49:15) ]--
|
| I have a list of names, separated by the '/' character in a variable,
| $list, and a name in the variable $name. If the name appears in the
| list, I want to remove it and clean up $list. It takes me 4 calls to
|
December 11, 2002 2:49 PM
Subject: Removing a name from a list - advanced regexp - TIMTOWTDI
> I have a list of names, separated by the '/' character in a variable,
$list,
> and a name in the variable $name. If the name appears in the list, I want
to
> remove it and clean up $
I have a list of names, separated by the '/' character in a variable, $list,
and a name in the variable $name. If the name appears in the list, I want to
remove it and clean up $list. It takes me 4 calls to s///, and it looks
clunky. I have a feeling that someone out there on this list will k
13 matches
Mail list logo