$check_text = $_POST["check_text"]; //フォームから受け取ります
$match_text = $_POST["match_text"];
$ereg_type = $_POST["ereg"];
if( $ereg_type =="preg_match_all" and preg_match("/^\//" ,$check_text) ==0 ){
$check_text = "/".$check_text."/";
}
//フォームが空か、単独の¥なら、初期値を入れます(エラー回避)
if( $check_text == "" or $check_text == "\\"){
$check_text = "ereg";
}
if( $match_text == ""){
$match_text = "text";
}
if( $ereg_type == ""){
$ereg_type = "mb_ereg";
}
//PHPのバージョンによっては、¥などの文字に、自動で¥を付加するので取り除きます。
$check_text = stripslashes($check_text);
$match_text = stripslashes($match_text);
//単純に、ereg()関数に入れて、判別します。
if( $ereg_type == "ereg" ){
$f = ereg( $check_text,$match_text,$a);
if( $f == false){
$res = "False No match.";
}else{
$res = "match OK. return ".$f."
";
//for($i=0; $i<$f; $i++){
$res = $res.print_r($a,true);
//}
}
}
if( $ereg_type == "mb_ereg" ){
$f = mb_ereg( $check_text,$match_text,$a);
if( $f == false){
$res = "False No match.";
}else{
$res = "match OK. return ".$f."
";
//for($i=0; $i<$f; $i++){
$res = $res.print_r($a,true);
//}
}
}
if( $ereg_type == "preg_match_all" ){
$f = preg_match_all( $check_text,$match_text,$a);
if( $f == false){
$res = "False No match.";
}else{
$res = "match OK. ".$f." time.
";
//for($i=0; $i<$f; $i++){
$res = $res.print_r($a,true);
//}
}
}
//HTMLを書き出します。
echo "
regular expression checker
PHP version
";
?>
readme