>> I have another problem, I have a string of nicknames that looks like:
>>
>> $mystring1 = "nick1,nick2,nick3,nick4,nick5";
>>
>> I've asked this question before, but because of my bad regex
>> knowledge, I'm asking again, but this time in a slightly different
>> context. The last time I asked, the string was:
>>
>> $mystring2 = "nick1 nick2 nick3 nick4 nick5";
>>
>> and I was given this regex: (assume $src contains "nick3")
>>
>> $mystring2 =~ s/(\s|^)\Q$src\E(?=\s|$)//g;
>>
>> I was told that this would remove the trailing space after $src, but
>> since now there is no trailing space, just a comma instead. What's
>> the alteration I need to make to this to remove $src from $mystring1?
>
> Replace the \s with a , and it will work for you.
It actually replaces the leading comma, so if $src contains nick1 you're
going to still have a leading space (now comma) on the string. It also
replaces all occurrences of $src in the string.
If you want it to work 'right' (i.e., snip the trailing comma if it is at
the beginning of the string, and the leading comma if it isn't), then try:
$mystring1 =~ s/(,)?\Q$src\E(,)?/$2?($1||''):''/ge;
/\/\ark
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]