PHP and Regular Expressions question?

Posted by php on Stack Overflow See other posts from Stack Overflow or by php
Published on 2010-03-18T04:12:12Z Indexed on 2010/03/18 4:21 UTC
Read the original article Hit count: 465

Filed under:
|

I was wondering if the codes below are the correct way to check for a street address, email address, password, city and url using preg_match using regular expressions?

And if not how should I fix the preg_match code?

preg_match ('/^[A-Z0-9 \'.-]{1,255}$/i', $trimmed['address']) //street address
preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'] //email address
preg_match ('/^\w{4,20}$/', $trimmed['password']) //password
preg_match ('/^[A-Z \'.-]{1,255}$/i', $trimmed['city']) //city
preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i", $trimmed['url']) //url

© Stack Overflow or respective owner

PHP and regular expressions question?

Posted by php on Stack Overflow See other posts from Stack Overflow or by php
Published on 2010-03-18T02:57:09Z Indexed on 2010/03/18 3:01 UTC
Read the original article Hit count: 465

Filed under:
|

What does the $/i mean in the following php code?

preg_match ('/^[A-Z \'.-]{2,20}$/i')

© Stack Overflow or respective owner

Related posts about php

Related posts about regular-expressions