hankknight
asked on
ASP.NET / VB / REGEX: Case Insensitive and at beginning, middle or end
The code below only changes matches that have a space on either side and are uppercase.
For example, "ak" should be replaced with "Alaska" however it is not because the case does not match. Also, "CA" should be replaced with "California" however it is not because it is at the end of the line.
For example, "ak" should be replaced with "Alaska" however it is not because the case does not match. Also, "CA" should be replaced with "California" however it is not because it is at the end of the line.
<%@ Page Language="VB" AutoEventWireup="false" %>
<%
Dim states As New Dictionary(of string, string)
states.add("AK", "Alaska")
states.add("AL", "Albama")
states.add("CA", "California")
Dim Xyz As String = "Lakes in ak are cold but it is always hot in AL and can be hot or cold in CA"
For Each state In states
xyz = xyz.Replace(" " & state.Key & " ", " " & state.Value & " ")
Next
Response.Write(xyz)
' Should say:
' Lakes in Alaska are cold but it is always hot in Alabama and can be hot or cold in California
%>
ASKER
Thanks, but that gives me an error:
Compiler Error Message: BC30002: Type 'RegExp' is not defined.
Have you tested it? Does it work for you?
Compiler Error Message: BC30002: Type 'RegExp' is not defined.
Have you tested it? Does it work for you?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window