View Full Version : Lil issue
Dean C
Sat 12th Jul '03, 8:39am
$nglow = '#FFFFFF';
if( ereg("^|#([A-Za-z0-9]{4})",$nglow,$testvar) )
{
echo "Invalid hex code";
}
That will work right to match a hex. Even when typed like so: #fFfFfF ?
- miSt
Scott MacVicar
Sat 12th Jul '03, 9:37am
$nglow = '#0f2452';
if (!preg_match('#\#(?:[A-F]|[0-9]){6}#i', $nglow))
{
echo 'invalid hex code';
}
what you have would only accept A-Z where hex is only A-F | 0-9
Dean C
Sat 12th Jul '03, 10:40am
Thankyou i'll give it a try now :)
Brb with results
____
Edit: It worked like a charm. I might be back later today with some more one's if i can't figure them out myself hehe :)
Thanks again
- miSt
Dean C
Sat 12th Jul '03, 11:04am
Ok i need one more. It needs to make sure that the variable $theurl starts with http:// and ends in .mid :)?
- miSt
MUG
Sat 12th Jul '03, 11:18am
if(preg_match('#^http://(.*)\.mid$#', $theurl)) {
// it matches
}
Scott MacVicar
Sat 12th Jul '03, 11:30am
evil code syntax ;)
and its case sensitive.
he really means
if (preg_match('#^http://(.*)\.mid$#s', $theurl))
{ // it matches
}
mfinc
Sat 12th Jul '03, 7:39pm
How about if you want to make .mid be able to be .html, .php, or .shtml. (a.k.a multiple string check at the end)
Son-Goku
Sat 12th Jul '03, 7:46pm
How about if you want to make .mid be able to be .html, .php, or .shtml. (a.k.a multiple string check at the end)
if (preg_match('#^http://(.*)\.(mid|html|php|shtml)$#s', $theurl))
{ // it matches
}
vBulletin® v3.8.0 Beta 4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.