<?
require_once( "./mwin.php" );
mb_language( "ja" );
mb_internal_encoding("EUC-JP");
foreach( $_POST as $Key => $Value ) {
$_POST[$Key] = str_replace("\\\\", "\\", $Value );
$_POST[$Key] = str_replace("\\'", "'", $_POST[$Key] );
$_POST[$Key] = str_replace("\\\"", "\"", $_POST[$Key] );
}
$_GET = $_POST;
?>
<HTML>
<HEAD>
<META http-equiv="Content-type" content="text/html; charset=euc-jp">
<TITLE>PHP 雛形</TITLE>
<LINK rel="stylesheet" type="text/css" href="style.css">
<STYLE type="text/css">
</STYLE>
</HEAD>
<BODY id="body" style='background-color:white'>
<?
if ( trim( $_GET['text'] ) == '' ) {
print "対象データを入力して下さい";
exit();
}
if ( trim( $_GET['pattern'] ) == '' ) {
print "パターンを入力して下さい";
exit();
}
if ( substr( $_GET['text'], 0, 4 ) == 'http' ) {
$ret = @file_get_contents( $_GET['text'] );
if ( $ret !== FALSE ) {
$enc = mb_detect_encoding($ret, "SJIS,UTF-8,EUC-JP");
if ( $enc == 'SJIS' || $enc == 'UTF-8' ) {
$ret = mb_convert_encoding ( $ret, "EUC-JP", $enc );
}
$_GET['text'] = $ret;
}
}
mb_ereg_search_init( $_GET['text'], $_GET['pattern'], "i" );
while( TRUE === mb_ereg_search() ) {
$work = mb_ereg_search_getregs();
$ncnt = 0;
foreach( $work as $Key => $Value ) {
$Value = mb_ereg_replace( "&", "&", $Value );
$Value = mb_ereg_replace( "<", "<", $Value );
$matches[$ncnt][] = mb_ereg_replace( ">", ">", $Value );
$ncnt++;
}
}
print "<pre>";
print "<span style='color:blue'>[0] は、マッチした全体の文字列を指す</span>\n";
print "<span style='color:blue'>それ以外は () によってマッチした部分文字列</span>\n";
print_r($matches);
print "</pre>";
?>
</BODY>
</HTML>