Open
Description
::URI::MailTo::EMAIL_REGEXP == /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/
Using the Regexp object works just fine. However, using the source in a rails query points out the error in the \z
escape squence at the end..
User.where("email ~* ?", ::URI::MailTo::EMAIL_REGEXP)
results in the following error:
ActiveRecord::StatementInvalid: PG::InvalidRegularExpression: ERROR: invalid regular expression: invalid escape \ sequence
::URI::MailTo::EMAIL_REGEXP.source == "\\A[a-zA-Z0-9.!\\\#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\\z"
The query is successful when I swap the lowercase z for an uppercase Z.
Metadata
Metadata
Assignees
Labels
No labels
Activity