Out of range errors in UITableView

Added a quick check to make sure that the matching location
wouldn't exceed the length of the string. This seemed to happen
in UITableView.