note 53335 modified in function.preg-match by mazzanet

From: Date: Tue, 31 May 2005 11:35:49 +0000
Subject: note 53335 modified in function.preg-match by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-89675@lists.php.net to get a copy of this message
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' ?> --was-- 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' ?> http://php.net/manual/en/function.preg-match.php

« previous php.notes (#89675) next »