Forum Moderators: coopster
$expression = "/å¦Å/i";
if (preg_match ($expression, $message))
{
print "has the last alphabet of you country";
} else {
print "no last alphabet of you country";
}
?>
[edited by: coopster at 7:53 pm (utc) on April 9, 2007]
[edit reason] no urls please TOS [webmasterworld.com] [/edit]
Have you looked at the PHP website for a better understanding of some of the regex functions?
[uk.php.net...]
dc
dreamcatcher:
yeah, i've been reading there and on, docforge.com & regexlib.com... i'm still clueless...hehe... u see, i have a type of readingdisorder =) i kinda need to see the code... not the whole code (i'm not stupid) all i need is a guidline... i just cant process lot's of theoretical content at the same time =)
sounds weird eh since i'm learning PHP haha =) dunno why, but somhow it works out =)
[edited by: clown at 3:16 pm (utc) on April 9, 2007]
$message = "hei på deg! skjærer du brød?";
$expression = "/(å¦Å)/(æ¦Æ)/(ø¦Ø)/[a-zA-Z]/i";
if (preg_match($expression, $message))
{
print "has the last alphabet of your country";
} else {
print "no last alphabet of your country";
}
?>
and got this:
Warning: preg_match(): Unknown modifier '(' in /var/www/00/43/75/example.com/www/phpschool/test/misc/ereg.php on line 15
Line 15: if (preg_match($expression, $message))
[edited by: eelixduppy at 6:30 pm (utc) on April 9, 2007]
[edit reason] exemplified error [/edit]
$message = "hei på deg! skjærer du brød?";
$expression = "/[å¦Å]¦[æ¦Æ]¦[ø¦Ø][a-zA-Z]/i";
if (preg_match($expression, $message))
{
print "has the last alphabet of your country";
} else {
print "no last alphabet of your country";
}
/*
it works for me... i guess this is what you looking for..
*/
?>
if (preg_match($expression, $message))
{
print "has the last alphabet of your country";
} else {
print "no last alphabet of your country";
}
?>
if you are copying my example right into your editor, try to replace the ¦ with the logical OR in you keyboard.. i mean, retype it again.. coz i think webmaster worlds re-encode this character...
$message = htmlentities($message);
$message = stripslashes($message);
if (preg_match($expression, $message))
{
print "has the last alphabet of your country";
} else {
print "no last alphabet of your country";
}
?>
or use [ kses ], try to search in google...
basicly the message is going to be validated the same way as an email using that regex() or whatever it was...
Email validation -> if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {