Jump to content

Can't figure why this doesn't work


steve m

Recommended Posts

Hello,

 

I am kind of new to regular expressions and I've been trying to get this script to work, but it won't.  I can't figure out why it doesn't work.  This is just a test script, but I want the preg-match() to find "\n".  The \n is posted through a form, and it seem like the preg_match() function is not reading the \ before the n, because it always comes up false.  Am I doing something wrong here?  I've tried several different ways to the pattern and nothing is working for me.

 

<?php
$strip_text = stripslashes($_POST["preg_text"]);

if(preg_match("/(n)/i", $strip_text))
{
	echo "It matched";
}

else
{
	echo "Did not Match";
}	
?>

Link to comment
https://forums.phpfreaks.com/topic/82226-cant-figure-why-this-doesnt-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.