hipromark
Members-
Posts
9 -
Joined
-
Last visited
Everything posted by hipromark
-
This is an example that I saw in php.net, there they say this pattern finds: 0, 1, alfabetic characters, or %, but it doesn't do that in my script, is it because I have to install something on PHP or what is happening? Here is the page from where I take the example (Is in spanish but may be it has a mirror page in english): http://tr2.php.net/manual/es/regexp.reference.character-classes.php
-
Hello, I am still having trouble with regular expressions. I made this script: <?php if (isset($_POST['submit'])) { $pattern = '#^[01[:alpha:]%]$#'; $string = $_POST['name']; if(!preg_match($pattern, $string)) { echo 'please use valid characters'; } else { echo 'Name format is correct'; } } Ok so when I run this script, even if I use alphabetic caracters, 1, 2, or % the message I receive is "please use valid characters", so the pattern is not recognized by PHP What am I doing wrong? Can anybody tell me?
-
Ok. Now I did this: $pattern = '^[[:alpha:]\.\' \-]{4,}$'; $string = $_POST['nombre']; if(!preg_match($pattern, $string)) { echo '<p>please enter a valid name</p>'; } else { echo 'Your name is ok'; } ?> And I get this error message: Warning: preg_match() [function.preg-match]: No ending delimiter '^'
-
Thanks for your help, but how can I use preg_match_all in the same way as eregi and ereg are used in script 10.7. I need to do somethimng like: if (!eregi ('^[[:alpha:]\.\' \-]{4,}$', stripslashes(trim($_POST['name'])))) { $problem = TRUE; $message .= '<p>Please enter a valid name.</p>'; If I use preg_match_all I have to specify $matches, i don´t know how to handle $matches!