Add several useful functions

Also, perhaps using `indexOf` would be better here - avoids allocating a new string.