Support the ongoing development of Laravel.io →
posted 10 years ago
Input

I am trying to do a basic "contact us" page with a message text area that allows for regular communication values. I have it working for the most part, however, I can't seem to get the newline to work. I have tested out my regex on a number of different online "regex testers" and it works there. But when I try to pass the message with "asdf asdf [newline] asdf", it fails validation. If I take out the newline, it passes validation.

// message can only be alphanumeric, newline, space, or dash and has to be greater than 10 characters
'msg' => 'required|regex:/^[\w\-\. \n]+$/|min:10', 
Last updated 3 years ago.
0

Anyone have a thought on why the regex is not working?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

landjea landjea Joined 5 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.