Skip to content

::URI::MailTo::EMAIL_REGEXP uses lowercase z for string-end anchor #43

Open
@foohooboo

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions