mIRC Homepage
Posted By: b1ink $removex - 16/10/06 03:31 PM
Hi. How about an identifier to remove an occurrence of substring. but single remove. example below:

//if ($remove(aaabb,b)) echo $ifmatch
* above will return aaa as we all now.

//if ($removex(aaabb,b)) echo $ifmatch
* above will just remove the first matched occurrence which will return aaab

I made a worked-around snippet. but I wish to see this feature to be built-in.
Posted By: qwerty Re: $removex - 16/10/06 03:59 PM
Nice idea. Better yet, make it $removex(string,sub,N[,sub,N,...]), removing the Nth occurrence of <sub> in <string>. N could be negative (removing from the right) or zero (removing all occurrences).
Posted By: b1ink Re: $removex - 16/10/06 04:04 PM
That's even better qwerty smile
Posted By: DaveC Re: $removex - 16/10/06 11:16 PM
Just to throw a spanner around the room, should each following "sub,N" be based apon the original string or the resulting string as it stands at the time of reaching the said "sub,N" ?
Posted By: qwerty Re: $removex - 16/10/06 11:36 PM
Heh, good point. Maybe the name $removex should be reserved for the identifier similar to $replacex. I can't come up with a short and descriptive name for this one ($removeone/$removeonex doesn't sound quite right).
Posted By: Mpdreamz Re: $removex - 17/10/06 09:47 AM
$remove already targets the string as it is when it reaches the nex parameter
$remove(abed,abe,ed)
Would leave Null when you target the input string alone but it returns d because "abe" was removed and ed wasn't found anymore.
$removex() should target the input string alone (like $replacex does) and shouldnt be complicated with N parameters IMO because then $remove and $removex wouldn't work in the same matter as $replace and $replacex .
Maybe $removeps() would be a good name ? and $removepsex() smile ps meaning position sensitive.

Ps: explanation not targeted at anyone in this thread wink

EDIT: Just realised $removepsex() would be subject to jokes and laughter :tongue:
Posted By: billythekid Re: $removex - 17/10/06 10:58 PM
/me jokes and laughs...


pee sex haha

btk blush grin smile
© mIRC Discussion Forums