Reverted parts of the last changes regarding avoid exception with regular expressions