hankknight
asked on
ASP.NET / VB / REGEX: Test for match instead of replace
The code below replaces matches inside a string. Instead of replacing all matches inside the string, I want the entire string to be replaced if there is a match.
The string should become empty if there is no match and it should contain the full word if there is a match.
Please test this:
The string should become empty if there is no match and it should contain the full word if there is a match.
Please test this:
<%@ Page Language="VB" AutoEventWireup="false" %>
<%
Dim str As String
str = "in is a state in America near Michigin"
str = RegularExpressions.Regex.Replace(str, "(?i)\bin\b", "Indiana")
Response.Write(str)
' Should return "Indiana"
Response.Write("<hr />")
str = "Testing 123"
str = RegularExpressions.Regex.Replace(str, "(?i)\bin\b", "Indiana")
Response.Write(str)
' Should not return anything
%>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.