fork download
  1. Imports System
  2. Imports System.Text.RegularExpressions
  3.  
  4. Public Class Test
  5. Public Shared Sub Main()
  6. Dim strProhibitedWord As String = "fox"
  7. Dim strProhibitedWordEnclosed As String = "(?<!\p{L})(" & strProhibitedWord.Substring(0,1) & ")" & strProhibitedWord.Substring(1) & "(?!\p{L})"
  8. Dim strSentence1 As String = "The quick brown Fox jumped over the foxy sheep to see his fox friend."
  9. Dim optOptions1 As RegexOptions = RegexOptions.IgnoreCase
  10. Dim strResult As String = Regex.Replace(strSentence1, strProhibitedWordEnclosed, "$1**", optOptions1)
  11.  
  12. Console.WriteLine(strResult)
  13. End Sub
  14. End Class
Success #stdin #stdout 0.07s 27696KB
stdin
Standard input is empty
stdout
The quick brown F** jumped over the foxy sheep to see his f** friend.