The commas separate the input into different parts in identifiers. With $1- it'll read all the parts, but the commas will also be removed, since they're considered separators.

The commas are only a problem if you define the input manually, i.e. $reverse(Hello, world and, stuff!), so using the identifier in text event/alias/whatever where the input comes from the user/whatever, i.e. $reverse($1-) or $reverse(%variable), won't be a problem.

The $regsubex version works pretty much exactly the same as the while loop one, except it's more efficient. It's probably easier to break the while loop one into parts and study it, you'll get the same result, except it's probably easier to understand, tweak and play around with.


EDIT:
I'm bored, so:
Code:
;Start of the alias called "reverse".
alias reverse {

  ;Set local variable %x to 1 and unset %r.
  var %x = 1,%r

  ;Loop, which continues as long as $mid returns something.
  ;$1 being the input, %x being the position and 1 being the amount of characters $mid is allowed to return at once.
  ;It literally goes character by character the given input until it reaches the end, which is $null.
  while ($mid($1,%x,1) != $null) {

    ;Set local variable %r to whatever $mid returned in the loop above ($v1), and attach it to the left side of whatever is in %r, if there is anything.
    var %r = $+($v1,%r)

    ;Increase %x by 1.
    inc %x
  }

  ;Return the result.
  return %r
}

Last edited by Dazuz; 16/12/15 04:57 PM. Reason: Boredom strikes!