You are here: allowing single quote in preg_match « PHP Programming Language « IT news, forums, messages
allowing single quote in preg_match

Posted by Mark Woodward on 10/11/06 12:40

Hi all,

I'm trying to validate text in a HTML input field.
How do I *allow* a single quote?

// catch any nasty characters (eg !@#$%^&*()/\)
$match = '/^['\w\.\-_?!, ]+$/';
$valid_srch = preg_match($match, $res_description);
if (!$valid_srch) {
...
}



for $match I've also tried:

$match = '/^[\'\w\.\-_?!, ]+$/';

$match = '/^["\w\.\-_?!, ]+$/';

$match = "/^['\w\.\-_?!, ]+$/";

$match = "/^[\'\w\.\-_?!, ]+$/";

and numerous other strings but always ' is seen as an
invalid character.


thanks,


--
Mark

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация