我试图用一个正则表达式命令消除两个特定文本字符串之间的所有文本。原文如下:
<html>
<!-- template name: text.tpl -->
<head>
<title>Cross-Collection Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="/t/text/textclass.js" language="JavaScript"></script>
<link rel="STYLESHEET" type="text/css" href="/t/text/textclass.css">
<link rel="stylesheet" href="/t/text/textclass-specific.css" type="text/css">
<script src="/t/text/bbagWindow.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript">
<!--
window.name = "mainwindow";
//-->
</script>
</head>
<!-- -------------------------------------------------- -->
<body bgcolor="#FFFFFF" marginwidth="0" marginheight="0">
<!-- -------------------------------------------------- -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="54" class="hdrcolor" background="/t/text/graphics/hdr-bg1.gif">
<a name="top"></a>
<a href="http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr;c=sampletc;cc=ecfr;xc=1;sid=75189253ab69c67a4a0484a5acb0c128;tpl=%2Fusr%2Flocal%2Fdlxs%2Fweb%2Ft%2Ftext%2Fhome.tpl" target="_top"><img src="/t/text/graphics/umdlt-smbanner.gif" border="0"></a></td>
<td height="54" class="hdrcolor" align="right" valign="top" background="/t/text/graphics/hdr-bg2.gif">
<table border="0" cellspacing="1" cellpadding="3">
<tr>
<td align="right" nowrap valign="top" bgcolor="#CCCCCC"> <font size="-1"><a class="globnav" href="">Authorized user login</a></font> </td>
<td align="right" bgcolor="#FFCC66" nowrap> <font size="-1"><a class="globnav" href="javascript:popupBBagWindow( 'http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr;c=sampletc;cc=ecfr;xc=1;sid=75189253ab69c67a4a0484a5acb0c128;page=bbaglist' , true )">View
bookbag</a></font> </td>
</tr>
</table>
<font class="navinfo" size="2"><br>your bookbag has <strong>0</strong> items</font>
</td>
</tr>
<!-- BEGIN rows outlining the navigation proper -->
<!-- this row contains a table controlling layout for the top border lines of the navbar -->
<tr>
<td class="navcolor" colspan="2" align="left" height="1" nowrap>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- home -->
<td width="70" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<td width="1"><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<!-- search -->
<td width="90" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<td width="1"><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<!-- browse -->
<td width="75" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<!-- blankspace -->
<td width="75" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<!-- help -->
<td width="75" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
</tr></table>
</td>
</tr>
<!-- this row contains a table controlling layout for the nav tabs themselves -->
<tr>
<td class="navcolor" colspan="2" align="left" bgcolor="#666699" height="23" nowrap>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- home -->
<td width="70" height="23" align="center" nowrap><font class="navlinks" color="#ffffff"><a href="http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr;c=sampletc;cc=ecfr;xc=1;sid=75189253ab69c67a4a0484a5acb0c128;tpl=%2Fusr%2Flocal%2Fdlxs%2Fweb%2Ft%2Ftext%2Fhome.tpl" class="nav">Home</a></font></td>
<!-- search -->
<td width="90" height="23" align="center" nowrap><font class="navlinks" color="#000000"><a href="http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr;c=sampletc;cc=ecfr;xc=1;sid=75189253ab69c67a4a0484a5acb0c128;page=simpleext" class="nav">Search</a></font></td >
<!-- browse -->
<td width="90" height="23" align="center" nowrap><font class="navlinks" color="#ffffff"><a href="http://ecfr.gpoaccess.gov/cgi/t/text/text-idx?c=ecfr;cc=ecfr;xc=1;sid=75189253ab69c67a4a0484a5acb0c128;tpl=browse.tpl" class="nav">Browse</a></font></td >
<!-- blankspace -->
<td width="50" height="23" align="center" nowrap> </td >
<!-- help -->
<td width="70" height="23" align="center" nowrap><font class="navlinks" color="#ffffff"><a href="/t/text/help" target="helpwin" class="nav">Help</a></font></td >
</tr>
</table>
</td >
</tr>
<!-- this row contains the table that controls layout for the lower nav border lines -->
<tr>
<td class="navhrcolor" colspan="2" align="left" height="1" nowrap bgcolor="#999999">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<td width="1"><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<td width="90" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<td width="1"><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<td width="75" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
<td width="75" height="1" align="center" nowrap><img src="/t/text/graphics/plug.gif" width="1" height="1" border="0"></td>
</tr></table>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="5" width="100%">
<tr>
<td valign="top" nowrap>
<hr size="1">
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="15">
<tr>
<td>
<br>
<strong><span class=mainheader>
正则表达式搜索和替换后完成的文本需要如下所示:
<html>
<strong><span class="mainheader">
出于某种原因,仅使用以下内容不起作用。为什么呢?
<html>(.*)<strong><span class=mainheader>
答案 0 :(得分:2)
您可能需要点击全部模式(使.
与新行字符匹配),或者只需将.
替换为[\s\S]
(这可确保所有字符都匹配,无论是否你的语言是否支持dot-all模式。)