Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Test your Search and replace Regular Expression

Total Hit ( 2729)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Test your Regular expression and also test Search and replace with regular expression

Click here to see Live Demo...

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()
   'txtOutput.text=TrimEx(txtInput.text)
  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*$)"
   'Create a regular expression object
    Dim re As New System.Text.RegularExpressions.Regex(txtSearchPattern.text)
  
   'Use the replace method to perform the formatting
  
    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&nbsp;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 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.