Skip to content

Edited the email regex in config/initializers to remove a multiline a…#5723

Open
mikeh-dev wants to merge 1 commit intoheartcombo:mainfrom
mikeh-dev:fix/emailregex
Open

Edited the email regex in config/initializers to remove a multiline a…#5723
mikeh-dev wants to merge 1 commit intoheartcombo:mainfrom
mikeh-dev:fix/emailregex

Conversation

@mikeh-dev
Copy link

Environment
Ruby 3.1.2
Rails 7.0.7
Devise 4.9.4
Current behaviour
I ran into a failing test with Rspec on the valid email check

The original regex here;

config.email_regexp =/^([\w.%+-]+)@([\w-]+.)+([\w]{2,})$/i

was failing on a new line error

Solution
I corrected to

/\A([\w.%+-]+)@([\w-]+.)+([\w]{2,})\z/i

Basically the same but changing the start and end removed the multiline anchors error for me.
OLD uses ^ and $: Matches start/end of any line
NEW uses \A and \z: Matches start/end of entire string

@carlosantoniodasilva carlosantoniodasilva added this to the 5.1.0 milestone Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants