首页 \ 问答 \ python 求问re模块匹配模式使用方法

python 求问re模块匹配模式使用方法

>>>m=re.match(r'www\.(.*)\..{3}','www.python.org') >>>m.group(1) 'python' >>>m.statr(1) 4 >>>m.end(1) 10 >>>m.span(1) (4,10) 如上程序,请问\..{3} 是什么意思?是怎么匹配到www.python.com的,求详解?
更新时间:2022-09-28 15:09

最满意答案

给你个简单例子,如下:

<form id="form1" name="form1" method="post" action="public.php">
 <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
 <td height="30" colspan="2" align="left" valign="middle">新闻发布</td>
 </tr>
 <tr>
 <td width="104" height="30" align="center" valign="middle">标题</td>
 <td width="396"><input type="text" name="title" id="title" /></td>
 </tr>
 <tr>
 <td height="30" align="center" valign="middle">类别</td>
 <td><select name="select" id="select">
 <option value="0">请选择类别</option><!--此处应为从数据库存读取,这里就不写出来-->
 <option value="1">房产</option>
 <option value="2">新闻</option>
 <option value="3">娱乐</option>
 </select></td>
 </tr>
 <tr>
 <td height="30" align="center" valign="middle">内容</td>
 <td><textarea cols="30" rows="10"></textarea></td>
 </tr>
 <tr>
 <td height="30" colspan="2" align="center" valign="middle"><input type="submit" name="button" id="button" value="提交" />
 <input type="reset" name="button2" id="button2" value="重置" /></td>
 </tr>
 </table>
</form>

-------------------------------------
外理页面
<?php
/* 
数据库简单结构
Info_ID 编号
Info_Title 标题
Info_Content 内容
Info_AddTime 时间
Info_type 类别
*/
 $title = $_POST['title'];
 $type = $_POST['type'];
 $content = $_POST['content'];
 $link = mysql_connect("localhost", "用户名", "密码") or die("连接失败: " . mysql_error()); 
 $db = mysql_select_db("数据库存名",$link); 
 mysql_query("set names gbk"); 
 $sql = "INSERT INTO `info` ( `Info_Title` , `Info_Content` , `Info_AddTime` , `Info_type` ) 
 VALUES ('".$InfoTitle."', '".$infoContents."', '".date("Y-m-d H:i:s")."', '".$type."')";
 mysql_query($sql,$link);
 echo "发布成功!";
?>

相关问答

更多