Page 1 of 1

expression issue

Posted: Mon Dec 03, 2007 3:02 am
by itsmani1
Hi all

I am having an expression issue, this code works fine but if i tired testing it using form it don't work.

Code: Select all

$regex='/^[a-zA-Z0-9_\.\-\;\:\'\"\/ ]{5,95}$/';
echo preg_match($regex, 'NEW Sony\'s 3.0" L.C.D. - 12MP DIGITAL CAMERA/VIDEO/TOUCH SENSOR K38');
here is my form code:

Code: Select all

<form id="form1" name="form1" method="post" action="test1.php">
  <input name="textfield" type="text" value="NEW Sony\'s 3.0" L.C.D. - 12MP DIGITAL CAMERA/VIDEO/TOUCH SENSOR K38" size="75" />
  <input type="submit" name="Submit" value="Submit" />
</form>
on submit this will give me 0.

any help

thank you

Posted: Mon Dec 03, 2007 9:38 am
by feyd
Note the double quote in the middle of the value in the form data. Also note the backslash before the single quote in the same value of the form.

Your regex attempts to match the entire input; it breaks at the backslash.