preg_match question

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
kyle04
New php-forum User
New php-forum User
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm

Re: preg_match question

Post by kyle04 » Wed Oct 03, 2012 3:12 pm

Code: Select all

if(
  preg_match('/[^a-zA-Z]/', stripslashes(trim($_POST['city'])))
){
// nasty characters
}  

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: preg_match question

Post by seandisanti » Thu Oct 04, 2012 3:30 pm

Code: Select all

<?php 
$city = "1test1";
$pattern = '[\d]';
$city = preg_replace($pattern,'',$city);
echo $city;
?>

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests