removed rexreplace
implemented substr negative argument handling