Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 915 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
<?php
2
 
3
function isColor($color) {
4
	//return preg_match('/(#[\dA-Fa-f]{6}|[A-Za-z]+|rgb\(\d{1,3},\d{1,3},\d{1,3}\))/', $color);
5
	return preg_match('/#[\dA-Fa-f]{6}/', $color);
6
}
7
 
8
function isNumeric($value, $nonNegative = false) {
9
	if ($nonNegative) {
10
		$pattern = '/\d+(.\d)*/';
11
	} else {
12
		$pattern = '/-?\d+(.\d)*/';
13
	}
14
	return preg_match($pattern, $value);
15
}
16
 
17
function isLengthValue($value, $nonNegative = false) {
18
	if ($nonNegative) {
19
		$pattern = '/\d*.?\d+(pt|cm|mm)/';
20
	} else {
21
		$pattern = '/-?\d*.?\d+(pt|cm|mm)/';
22
	}
23
	return preg_match($pattern, $value);
24
}
25
 
26
function isPercentage($value) {
27
	return preg_match('/\d+(.\d)*%/', $value);
28
}
29
 
30
?>