|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
<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> 返回类别: 教程 上一教程: 第三节--定义一个类 -- Classes and Objects in PHP5 [3] 下一教程: 十天学会php之第六天 您可以阅读与"正则表达式例子:在一个字符串中查找另一个字符串"相关的教程: · 正则表达式例子:在一个字符串中查找另一个字符串 · 正则表达式例子:获得某个网页上的所有超裢接 · 正则表达式例子:将MM/DD/YYYY格式的日期转变为YYYY-MM-DD格式 · 正则表达式例子:获得某个网页上的所有超裢接 · 正则表达式例子:将MM/DD/YYYY格式的日期转变为YYYY-MM-DD格式 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |