正则表达式将asp页面response.writes转换为html

发布于 2024-11-07 22:39:38 字数 8866 浏览 3 评论 0原文

我有这个...

Response.write "<table width=""700"" border=""0"">"

    Response.write "<tr><td width=""10%"">&nbsp;<td align=center pagetitle2strong""><br><strong>Advanced Sales Search</strong><br><br></td></tr>"

    Response.write "<tr><td width=""10%"">&nbsp;<td>"

    ShowSearchDisclaimer    

    Response.write "<table border=0><tr><td width=""10%"">&nbsp;<td>"

    ShowForm

    Response.write "</td></td></tr></table>"

    Response.write "</td></tr></table>"

在查看源代码中看起来像这样...只是一个大斑点。

<table width="700" border="0"><tr><td width="10%">&nbsp;</td><td align="right" ><h1>Search Sales or Transfers</h1></td></tr><tr><td width="10%">&nbsp;</td><td><table width=600 border=0><tr><td><font size=+1><b>By using this page you are agreeing to the following disclaimer.</b></font></td></tr><tr><td>&nbsp;</td></tr><tr><td>The information appearing on this website was extracted from the records of the office of the Sarasota County Property Appraiser. Our goal is to provide you with the most accurate information possible. The information maintained on this website should not be relied upon for any purposes except for those of the Property Appraiser and his staff. The Sarasota County Property Appraiser accepts no responsibility for the inappropriate use or the misinterpretation of data. No warranties, expressed or implied, are provided for the data herein. The property values relate to the last valuation date, or to preliminary values when noted. The data is subject to change.</td></tr><tr><td>&nbsp;</td></tr><tr><td>By proceeding with a property search you are stating that the notice has been read and that you understand and agree with its contents. The data contained on this site is intended for information purposes only. It is based on the best information available at the time of posting and is not warranted. The data may not reflect the most current records.</td></tr><tr><td>&nbsp;</td></tr><tr><td><a href="/Content/Disclaimer.asp">View Full Disclaimer Here.</a></td></tr><tr><td>&nbsp;</td></tr></table><table><form METHOD=POST NAME=frmPrice ACTION=/search/sales_search_results.asp><tr><td FormDisplayText"><b>Recorded Consideration<p class="teaser">Sale Price</p></b></td><td align=right><input TYPE=text SIZE=8 NAME=AmtFrom title="Minimum Price">&nbsp;<input TYPE=text SIZE=8 NAME=AmtTo title="Maximum Price">&nbsp;<input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmDate ACTION=/search/sales_search_results.asp><tr><td FormDisplayText"><b>Transaction Date</b></td><td align=right><input TYPE=text SIZE=8 NAME=DateFrom title="Minimum Date">&nbsp;<input TYPE=text SIZE=8 NAME=DateTo title="Maximum Date">&nbsp;<input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmInstrument ACTION=/search/sales_instrument_search_results.asp><tr><td FormDisplayText"><b>Instrument Number</b></td><td align=right><input TYPE=text SIZE=22 NAME=kw1 title="Enter Complete or Partial Instrument Number">&nbsp;<input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmDeedType ACTION=/search/sales_deed_type_search_results.asp><tr><td FormDisplayText"><b>Instrument Type</b></td><td align=right><input TYPE=text SIZE=22 NAME=kw1 title="Enter Exact Deed Type">&nbsp;<input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmGrantor ACTION=/search/sales_grantor_search_results.asp><tr><td FormDisplayText"><b>Seller/Grantor</b></td><td align=right><input TYPE=text SIZE=8 name=kw1 title="Enter part of Grantor's Name">&nbsp;<input TYPE=text SIZE=8 name=kw2 title="Enter part of Grantor's Name">&nbsp;<input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmSubCode ACTION=/search/sales_search_results.asp?type=code><tr><td FormDisplayText"><b>Subdivision Code</b></td><td align=right><input TYPE=text SIZE=22 name=SubCode title="Enter exact Subdivision Code">&nbsp;<input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmSubName ACTION=/search/sales_search_results.asp?type=name><tr><td FormDisplayText"><b>Subdivision Name</b></td><td align=right><input TYPE=text SIZE=22 name=SubName title="Enter all or part of the Subdivision Name">&nbsp;<input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmUseCode ACTION=/search/sales_search_results.asp><tr><td FormDisplayText"><b>Land Use Code</b></td><td align=right><input TYPE=text SIZE=8 NAME=UseFrom title="Minimum LUC">&nbsp;<input TYPE=text SIZE=8 NAME=UseTo title="Maximum LUC">&nbsp;<input type=submit value=Submit title="Click to view search results"></td></tr></form><tr><td FormDisplayText">&nbsp;</td></tr><tr><td FormDisplayText"><b>Lookup Subdivision Code</b></td><td align=right><input type=button value=Lookup title="Click to lookup code values" onclick=location.href='/search/subdivision_codes.asp?type=sales'></td></tr></form><tr><td FormDisplayText"><b>Lookup Use Code</b></td><td align=right><input type=button value=Lookup title="Click to lookup code values" onclick=location.href='/search/use_codes.asp?type=sales'></td></tr></form><tr><td FormDisplayText"><b>Lookup Instrument Type</b></td><td align=right><input type=button value=Lookup title="Click to lookup code values" onclick=location.href='/search/deed_types.asp'></td></tr></form><tr><td FormDisplayText"><b>Lookup Transaction Qual. Codes</b></td><td align=right><input type=button value=Lookup title="Click to lookup code values" onclick=location.href='/search/sales_qualification_codes.asp'></td></tr></form></table></td></tr></table>

我想要一个正则表达式,可以让我快速 更改所有 response.write "" &有时带有变量 & "

TO

%>
<my html><%=somevariable%>
<%

另外,原始代码不遵循任何形式,因此属性值很少正确括在引号中。

我想这样做,因为它真的很难调试“blob”plus,当我在 IDE 中时,如果我错了,能够看到渲染的 html 就真的很高兴了,但这不是吗?使用大量服务器端资源?因为所有的response.write命令都必须在服务器端处理?无论如何,我真的很感激任何能想出一种方法来快速重新编码这种情况的人

Sub ShowCriteriaRow()

    If strPrint <> "yes" then 

        %>
        <br />
        <input type="text" id="kw1" name="kw1" size="20" value="<%=Keyword1 %>"/><%

        If (PageType <> "parcel" and PageType <> "lastname"and PageType <> "situs") Then 
            %>
        <input type="text" id="kw2" name="kw2" size="20" value="<%=Keyword2 %>"/><%
        End If

        If PageType = "STR" Then 
            %>
        <input type="text" id="kw3" name="kw3" size="20" value="<%=Keyword3 %>"/><%
        End If

        %>
        <input type="submit" name="submit" id="submit" value="Resubmit" /><%

        ShowExportButton

    Else
        Response.Write "<b>Keywords:</b> " & Keyword1 
            If Keyword2 <> "" Then Response.Write ", " & Keyword2
            If Keyword3 <> "" Then Response.Write ", " & Keyword3
        Response.Write "&nbsp; &nbsp; &nbsp; &nbsp;"
    End If  

    %>
        </td>
    </tr><%

这是一个开始,我不能改变太多的底层结构,因为它非常像意大利面条。

I have this...

Response.write "<table width=""700"" border=""0"">"

    Response.write "<tr><td width=""10%""> <td align=center pagetitle2strong""><br><strong>Advanced Sales Search</strong><br><br></td></tr>"

    Response.write "<tr><td width=""10%""> <td>"

    ShowSearchDisclaimer    

    Response.write "<table border=0><tr><td width=""10%""> <td>"

    ShowForm

    Response.write "</td></td></tr></table>"

    Response.write "</td></tr></table>"

Which in view source looks like this...just one big blob.

<table width="700" border="0"><tr><td width="10%"> </td><td align="right" ><h1>Search Sales or Transfers</h1></td></tr><tr><td width="10%"> </td><td><table width=600 border=0><tr><td><font size=+1><b>By using this page you are agreeing to the following disclaimer.</b></font></td></tr><tr><td> </td></tr><tr><td>The information appearing on this website was extracted from the records of the office of the Sarasota County Property Appraiser. Our goal is to provide you with the most accurate information possible. The information maintained on this website should not be relied upon for any purposes except for those of the Property Appraiser and his staff. The Sarasota County Property Appraiser accepts no responsibility for the inappropriate use or the misinterpretation of data. No warranties, expressed or implied, are provided for the data herein. The property values relate to the last valuation date, or to preliminary values when noted. The data is subject to change.</td></tr><tr><td> </td></tr><tr><td>By proceeding with a property search you are stating that the notice has been read and that you understand and agree with its contents. The data contained on this site is intended for information purposes only. It is based on the best information available at the time of posting and is not warranted. The data may not reflect the most current records.</td></tr><tr><td> </td></tr><tr><td><a href="/Content/Disclaimer.asp">View Full Disclaimer Here.</a></td></tr><tr><td> </td></tr></table><table><form METHOD=POST NAME=frmPrice ACTION=/search/sales_search_results.asp><tr><td FormDisplayText"><b>Recorded Consideration<p class="teaser">Sale Price</p></b></td><td align=right><input TYPE=text SIZE=8 NAME=AmtFrom title="Minimum Price"> <input TYPE=text SIZE=8 NAME=AmtTo title="Maximum Price"> <input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmDate ACTION=/search/sales_search_results.asp><tr><td FormDisplayText"><b>Transaction Date</b></td><td align=right><input TYPE=text SIZE=8 NAME=DateFrom title="Minimum Date"> <input TYPE=text SIZE=8 NAME=DateTo title="Maximum Date"> <input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmInstrument ACTION=/search/sales_instrument_search_results.asp><tr><td FormDisplayText"><b>Instrument Number</b></td><td align=right><input TYPE=text SIZE=22 NAME=kw1 title="Enter Complete or Partial Instrument Number"> <input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmDeedType ACTION=/search/sales_deed_type_search_results.asp><tr><td FormDisplayText"><b>Instrument Type</b></td><td align=right><input TYPE=text SIZE=22 NAME=kw1 title="Enter Exact Deed Type"> <input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmGrantor ACTION=/search/sales_grantor_search_results.asp><tr><td FormDisplayText"><b>Seller/Grantor</b></td><td align=right><input TYPE=text SIZE=8 name=kw1 title="Enter part of Grantor's Name"> <input TYPE=text SIZE=8 name=kw2 title="Enter part of Grantor's Name"> <input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmSubCode ACTION=/search/sales_search_results.asp?type=code><tr><td FormDisplayText"><b>Subdivision Code</b></td><td align=right><input TYPE=text SIZE=22 name=SubCode title="Enter exact Subdivision Code"> <input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmSubName ACTION=/search/sales_search_results.asp?type=name><tr><td FormDisplayText"><b>Subdivision Name</b></td><td align=right><input TYPE=text SIZE=22 name=SubName title="Enter all or part of the Subdivision Name"> <input type=submit value=Submit title="Click to view search results"></td></tr></form><form METHOD=POST NAME=frmUseCode ACTION=/search/sales_search_results.asp><tr><td FormDisplayText"><b>Land Use Code</b></td><td align=right><input TYPE=text SIZE=8 NAME=UseFrom title="Minimum LUC"> <input TYPE=text SIZE=8 NAME=UseTo title="Maximum LUC"> <input type=submit value=Submit title="Click to view search results"></td></tr></form><tr><td FormDisplayText"> </td></tr><tr><td FormDisplayText"><b>Lookup Subdivision Code</b></td><td align=right><input type=button value=Lookup title="Click to lookup code values" onclick=location.href='/search/subdivision_codes.asp?type=sales'></td></tr></form><tr><td FormDisplayText"><b>Lookup Use Code</b></td><td align=right><input type=button value=Lookup title="Click to lookup code values" onclick=location.href='/search/use_codes.asp?type=sales'></td></tr></form><tr><td FormDisplayText"><b>Lookup Instrument Type</b></td><td align=right><input type=button value=Lookup title="Click to lookup code values" onclick=location.href='/search/deed_types.asp'></td></tr></form><tr><td FormDisplayText"><b>Lookup Transaction Qual. Codes</b></td><td align=right><input type=button value=Lookup title="Click to lookup code values" onclick=location.href='/search/sales_qualification_codes.asp'></td></tr></form></table></td></tr></table>

I want a regular expression that will allow me to quickly
change all the response.write "<some html here>" & sometimes with variables & </more html>"

TO

%>
<my html><%=somevariable%>
<%

Also, the original code follows no form whatsoever, so rarely are attribute values correctly enclosed in quotations.

I want to do this because it is really hard to debug the "blob" plus, when I'm in the IDE, it'd be real nice to be able to see the rendered html. PLUS corret me if I'm wrong but isn't this using a lot of my server side resources? Since all of the response.write commands have to be processed server side? Anyways. I'd really appreciate anyone who can think of a way to quickly recode this type of a situation.

Here is a page I already did by hand...

Sub ShowCriteriaRow()

    If strPrint <> "yes" then 

        %>
        <br />
        <input type="text" id="kw1" name="kw1" size="20" value="<%=Keyword1 %>"/><%

        If (PageType <> "parcel" and PageType <> "lastname"and PageType <> "situs") Then 
            %>
        <input type="text" id="kw2" name="kw2" size="20" value="<%=Keyword2 %>"/><%
        End If

        If PageType = "STR" Then 
            %>
        <input type="text" id="kw3" name="kw3" size="20" value="<%=Keyword3 %>"/><%
        End If

        %>
        <input type="submit" name="submit" id="submit" value="Resubmit" /><%

        ShowExportButton

    Else
        Response.Write "<b>Keywords:</b> " & Keyword1 
            If Keyword2 <> "" Then Response.Write ", " & Keyword2
            If Keyword3 <> "" Then Response.Write ", " & Keyword3
        Response.Write "       "
    End If  

    %>
        </td>
    </tr><%

It's a start. I can't change too much of the underlying structure as it's pretty spaghetti like.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽手叙旧 2024-11-14 22:39:38

我不认为正则表达式是答案,也不适用于此。

就我个人而言,我会使用类似于以下内容的方法来解决您的问题,以使脚本和输出 HTML 更具可读性:

tableString  = "<table width=""700"" border=""0"">" & _
                    "<tr><td width=""10%""> <td align=center pagetitle2strong""><br><strong>Advanced Sales Search</strong><br><br></td></tr>" & _
                        "<tr>" & _
                        "<td width=""10%""> <td>" & _ 
                        "{SearchDisclaimer}" & _
                        "<table border=0>" & _
                            "<tr><td width=""10%""> <td>" & _
                                "{ShowForm}" & _
                            "</td></td></tr>" & _
                        "</table>" & _
                        "</td></tr>" & _
                "</table>"

tableString = replace(tableString, "{SearchDisclaimer}", ShowSearchDisclaimer())
tableString = replace(tableString, "{ShowForm}", ShowForm())

Response.write(tableString)

然后将您的 Subs 更改为将 HTML 作为字符串返回的函数,如下所示:

function ShowCriteriaRow()
    outputString = ""
    if strPrint <> "yes" then
        outputString = outputString & "<input id=""textbox"" name=""foo"" value=""bar"" />"
    end if

    ShowCriteriaRow = outputString
end function

I don't think Regex is the answer, nor applicable here.

Personally I'd solve your issue with something more like the following to make both the script and the output HTML much more readable:

tableString  = "<table width=""700"" border=""0"">" & _
                    "<tr><td width=""10%""> <td align=center pagetitle2strong""><br><strong>Advanced Sales Search</strong><br><br></td></tr>" & _
                        "<tr>" & _
                        "<td width=""10%""> <td>" & _ 
                        "{SearchDisclaimer}" & _
                        "<table border=0>" & _
                            "<tr><td width=""10%""> <td>" & _
                                "{ShowForm}" & _
                            "</td></td></tr>" & _
                        "</table>" & _
                        "</td></tr>" & _
                "</table>"

tableString = replace(tableString, "{SearchDisclaimer}", ShowSearchDisclaimer())
tableString = replace(tableString, "{ShowForm}", ShowForm())

Response.write(tableString)

Then change your Subs to functions which return HTML as a string such as this:

function ShowCriteriaRow()
    outputString = ""
    if strPrint <> "yes" then
        outputString = outputString & "<input id=""textbox"" name=""foo"" value=""bar"" />"
    end if

    ShowCriteriaRow = outputString
end function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文