原始文字如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestPage.aspx.cs" Inherits="VisualWebDeveloper._Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>TestPage.aspx</title>
<!--Autogeneous Head Code Start-->
<script type='text/javascript' src='/app/TestPage.aspx.js'></script>
HeadCode
<!--Autogeneous Head Code End-->
</head>
<body>
我想将以下的内容:
<!--Autogeneous Head Code Start-->
<script type='text/javascript' src='/app/TestPage.aspx.js'></script>
HeadCode
<!--Autogeneous Head Code End-->
进行替换,也就是以<!--Autogeneous Head Code Start-->开头,以<!--Autogeneous Head Code End-->
结尾的任意字符串被替换为目标字符串。
我写的表达式是:(?<=<!--Autogeneous Body Code Start-->\r\n)([\s\S]*)(?=\r\n<!--Autogeneous Body Code End-->)现在遇到的问题是,如果我将原始字符串和表达式放在一个TextBox中然后取出可以正常替换,但如果我将原始字符串和表达式在程序中直接赋值则不能正常替换和匹配,查了半天也找不到原因,请高手帮忙!先行叩谢!