The idea is to remove the first n occurrences of the 'match'; not keep the first n occurrences, thus there isn't a 'bug' in the iif.

Example:
Code:
Should remove the first 2 occurances
    $nremove(abab-abab, 2, ab) 

resulting in
    -abab


However, there is a typo/bug in $regesc where $3 should be $1:

Code:
alias -l regesc {
  return /(\Q $+ $replacecs($1, \E, \E\\E\Q) $+ \E)/ug $+ $prop
}

alias nremove {
  var %n = $2
  return $regsubex($1, $regesc($3).i, $iif(\n > %n, \1))
}

alias nremovecs {
  var %n = $2
  return $regsubex($1, $regesc($3), $iif(\n > %n, \1))
}

Last edited by FroggieDaFrog; 01/09/18 08:19 PM.

I am SReject
My Stuff