Better handling of bad and slow regex