I'm getting so fed up, all I want is a simple expression to allow A-Z a-z 0-9 .-!?@, and it should be between 4 and 60 characters long how come this doesn't work:
Code: Select all
if (eregi ('^[a-zA-Z0-9,.-!?@]{4,60}$', $blah)
Moderator: General Moderators
Code: Select all
if (eregi ('^[a-zA-Z0-9,.-!?@]{4,60}$', $blah)
Code: Select all
[a-c] // matches 'a', 'b' or 'c'
[-ac] // matches '-', 'a', 'c'
[ac-] // the same as the previousCode: Select all
if (eregi ('^[a-zA-Z0-9,-.@?!_]{4,60}$', stripslashes(trim($_POST['new_cat'])))) {
$c = str_replace(" ","_",escape_data($_POST['new_cat']));
} else {
$c = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid category!</font></p>';
}
I get the impression you didn't read my relpy at all! Because I didn't ask for an error message, I asked to supply a string that doesn't match but should match according you. And also, I told you at least one mistake in your regex, yet I still see it in your last post.andylyon87 wrote:Sorry dude, I am trying to pass a word into it and that is literally it as explained in the top post.
...
... it doesn't pose me a useful error just the else statement.
Code: Select all
<?php
if(eregi('^[a-zA-Z0-9,.@?!_-]{4,60}$', 'aB-?!')) {
echo "It does work.";
}
?>