在一个字符串中查找另一个字符串

王朝other·作者佚名  2008-05-21
窄屏简体版  字體: |||超大  

<html><head><title>正则表达式</title></head><body><a href="./">返回列表</a><br><form action="<?echo $PHP_SELF;?>" method="post">在<input type="text" name="string" value="<?echo $string;?>">中查找<input type="text" name="query" value="<?echo $query;?>"><br><input type="radio" name="where" value="" <?if(!isset($where) or $where=="") echo "checked";?>>第二个字符串可以在第一个字符串的任何位置<br><input type="radio" name="where" value="^" <?if(isset($where) and $where=="^") echo "checked";?>>第一个字符串以第二个字符串开始<br><input type="radio" name="where" value="$" <?if(isset($where) and $where=="$") echo "checked";?>>第一个字符串以第二个字符串结束<br><input type="checkbox" name="case" value="case" <?if(isset($case)) echo "checked";?>>区分大小写<br><input type="submit" value="查询"></form><?if(isset($string) and isset($query) and $string<>"" and $query<>""){

if(isset($case)){

$func = "ereg";

}

else{

$func = "eregi";

}

switch($where){

case "^":

$query = "^" . $query;

break;

case "$":

$query .= "$";

break;

}

eval("$found = $func("$query","$string");");

if($found){

echo "找到!";

}

else{

echo "未找到!";

}}?></body></html>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航