migrated code from RegExDBSearch so scripts are not dependant on it