therealwesfoster Posted March 25, 2008 Share Posted March 25, 2008 I'm wanting to allow "newline" characters in my preg_match. But how? My code preg_match("/^[\ 0-9a-zA-Z\-_]+$/",$_POST['choices']); Thanks Quote Link to comment https://forums.phpfreaks.com/topic/97714-regex-for-newline/ Share on other sites More sharing options...
MadTechie Posted March 25, 2008 Share Posted March 25, 2008 preg_match("/^[\ 0-9a-zA-Z\_\n-]+$/m",$_POST['choices']); edit: added the multiline switch and moved the - to the end Quote Link to comment https://forums.phpfreaks.com/topic/97714-regex-for-newline/#findComment-499988 Share on other sites More sharing options...
therealwesfoster Posted March 25, 2008 Author Share Posted March 25, 2008 You da man madtechie I modded your code though and am using \r\n. It works just the same Wes Quote Link to comment https://forums.phpfreaks.com/topic/97714-regex-for-newline/#findComment-499990 Share on other sites More sharing options...
MadTechie Posted March 25, 2008 Share Posted March 25, 2008 as a side note have the - at the start or end otherwise it will try to create a range Quote Link to comment https://forums.phpfreaks.com/topic/97714-regex-for-newline/#findComment-499992 Share on other sites More sharing options...
therealwesfoster Posted March 25, 2008 Author Share Posted March 25, 2008 Good advice. Thanks again. (where'd the topic solved mod go?) Quote Link to comment https://forums.phpfreaks.com/topic/97714-regex-for-newline/#findComment-499999 Share on other sites More sharing options...
MadTechie Posted March 25, 2008 Share Posted March 25, 2008 Forum has been updated (i think) that mod didn't get re-added, i guess its hard to find a PHP developer nowdays .. i am not sure why it hasn't been added back Quote Link to comment https://forums.phpfreaks.com/topic/97714-regex-for-newline/#findComment-500004 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.