<?
// preg_match('/[0-9a-zA-Z.]+/', $FileName, $Result);
function test($ch) {
/*if(eregi("/^[a-z0-9_-]+$/i", $ch)) {
echo "ok";
}else{
//$pattern = "^[a-zA-Z0-9*|]";
//$replace_ch = preg_replace($pattern, '', $ch);
//echo $replace_ch;
echo "no";
} */
/*preg_match('/[0-9a-zA-Z\*\|]+$/i', $ch ,$result , PREG_OFFSET_CAPTURE) ;
if($result[0][0] == $ch ){
echo "ok";
echo "<br>";
echo $ch;
echo "<br>";
}else{
preg_match('/[0-9a-zA-Z\*\|]+/', $ch ,$result1 , PREG_OFFSET_CAPTURE) ;
$rs = $result[0][0].$result1[0][0] ;
echo "no";
echo "<br>";
echo $result[0][0];
echo "<br>";
echo $result1[0][0];
echo "<br>";
echo $ch." ---> ".$rs;
}
*/
preg_match('/[0-9a-zA-Z\*\|]+$/i', $ch ,$result) ;
if($result[0] == $ch ){
echo "ok";
echo "<br>";
echo $ch;
echo "<br>";
echo $result[0];
}else{
echo "no";
echo "<br>";
echo $result[0];
}
}
/*
function test($ch) {
preg_match('/[0-9a-zA-Z\*\|]+$/i', $ch ,$result , PREG_OFFSET_CAPTURE) ;
if($result[0][0] == $ch ){
echo "ok";
echo "<br>";
print_r($result);
}else{
echo "no";
echo "<br>";
print_r($result);
}
}
*/
$id = "a!b123**||!*|*";
test($id);
?>
출처 : http://blog.shypepe.com/150021787717
// preg_match('/[0-9a-zA-Z.]+/', $FileName, $Result);
function test($ch) {
/*if(eregi("/^[a-z0-9_-]+$/i", $ch)) {
echo "ok";
}else{
//$pattern = "^[a-zA-Z0-9*|]";
//$replace_ch = preg_replace($pattern, '', $ch);
//echo $replace_ch;
echo "no";
} */
/*preg_match('/[0-9a-zA-Z\*\|]+$/i', $ch ,$result , PREG_OFFSET_CAPTURE) ;
if($result[0][0] == $ch ){
echo "ok";
echo "<br>";
echo $ch;
echo "<br>";
}else{
preg_match('/[0-9a-zA-Z\*\|]+/', $ch ,$result1 , PREG_OFFSET_CAPTURE) ;
$rs = $result[0][0].$result1[0][0] ;
echo "no";
echo "<br>";
echo $result[0][0];
echo "<br>";
echo $result1[0][0];
echo "<br>";
echo $ch." ---> ".$rs;
}
*/
preg_match('/[0-9a-zA-Z\*\|]+$/i', $ch ,$result) ;
if($result[0] == $ch ){
echo "ok";
echo "<br>";
echo $ch;
echo "<br>";
echo $result[0];
}else{
echo "no";
echo "<br>";
echo $result[0];
}
}
/*
function test($ch) {
preg_match('/[0-9a-zA-Z\*\|]+$/i', $ch ,$result , PREG_OFFSET_CAPTURE) ;
if($result[0][0] == $ch ){
echo "ok";
echo "<br>";
print_r($result);
}else{
echo "no";
echo "<br>";
print_r($result);
}
}
*/
$id = "a!b123**||!*|*";
test($id);
?>
출처 : http://blog.shypepe.com/150021787717
'프로그래밍 > PHP' 카테고리의 다른 글
PHP 작업시 도움이 되는 함수 (0) | 2010.01.20 |
---|---|
PHP 이미지 변환 BMP to JPG (0) | 2009.12.09 |
Smarty에서 javascript 처리 하기 PHP (0) | 2009.10.21 |
함수 존재 확인, 메소드 존재 확인 (0) | 2009.10.01 |
.htaccess 파일 관련 (0) | 2009.09.25 |