|
|
|
Click here to copy the following block | <%@ Page Language="VB" Debug="true" %> <%@ import Namespace="System.Data.SqlClient" %> <script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs) lblMatch.text=CheckExpression() SearchReplace() End Sub function CheckExpression() as string Dim re As New System.Text.RegularExpressions.Regex(txtSearchPattern.text) if re.IsMatch(txtInput.text) then CheckExpression="Match" lblMatch.Forecolor=System.Drawing.Color.Blue else CheckExpression="No Match" lblMatch.Forecolor=System.Drawing.Color.Red end if end function sub SearchReplace() Dim reg1 As String = "^(\s*)([\W\w]*)(\b\s*$)" Dim re As New System.Text.RegularExpressions.Regex(txtSearchPattern.text) txtOutput.text = re.Replace(txtInput.text, txtReplacePattern.text) End sub
</script> <html> <head> </head> <body> <form runat="server"> <p> <table style="WIDTH: 681px; HEIGHT: 266px" width="681"> <tbody> <tr> <td> <strong>Input String</strong></td> <td> <strong>Output</strong></td> </tr> <tr> <td> <asp:TextBox id="txtInput" runat="server" TextMode="MultiLine" Height="142px" Width="100%"> Dim I as Integer</asp:TextBox> </td> <td> <asp:TextBox id="txtOutput" runat="server" TextMode="MultiLine" Height="137px" Width="100%"></asp:TextBox> </td> </tr> <tr> <td> <p> <asp:Button id="Button1" onclick="Button1_Click" runat="server" Width="189px" Text="Search / Replace"></asp:Button> </p> </td> <td> <asp:Label id="lblMatch" runat="server" width="301px"></asp:Label></td> </tr> <tr> <td> <strong>Search pattern</strong></td> <td> <strong>Replace Pattern</strong></td> </tr> <tr> <td> <p> <asp:TextBox id="txtSearchpattern" runat="server" TextMode="MultiLine" Height="47px" Width="100%">^(\s*)([\W\w]*)(\b\s*$)</asp:TextBox> </p> </td> <td> <p> <asp:TextBox id="txtReplacePattern" runat="server" TextMode="MultiLine" Height="47px" Width="100%">$2</asp:TextBox> </p> </td> </tr> </tbody> </table> </p> <!-- Insert content here --> </form> </body> </html> |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|