note 53335 deleted from function.preg-match by tularis
| From: | tularis@php.net | Date: | Tue, 31 May 2005 12:51:44 +0000 |
| Subject: | note 53335 deleted from function.preg-match by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-89676@lists.php.net to get a copy of this message | ||
Note Submitter: sam at macrepublic dot com
----
I started learning PHP about 2 years ago and have used this site often for research and reference.
What I've noticed is that notes from other visitors, tend NOT to be direct and to the point.
The whole thing about scripting / coding / programming isn't about showing someone a whole
script it's about taking the principles of various parts of the language and adapting them to
suit your needs. For example, take this function, preg_match, you won't find a very simple
usage of it. Some of us just want to know its basics and here it is.
<?php
// This script will return a 1 if the e-mail address is formatted properly
// and a 0 if it is not.
$string1 = "username@email.com";
$string2 = "somethingwrong";
$format = "/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/"; \\ My Regular Expression
$test1 = preg_match($format, $string1);
$test2 = preg_match($format, $string2);
print($test_1); // Will output '1'
print($test_2); // Will output '0'
?>