Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. string comparision ignores escape sequence and html tags [modified]

string comparision ignores escape sequence and html tags [modified]

Scheduled Pinned Locked Moved C#
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LiYS
    wrote on last edited by
    #1

    Hi all, Is there any build in string comparison or filter method that could ignore escaped character(like /r/n) & html tags(like
    )? I've tried the regular expression like "Regex.Replace(xml, "\\.", "");" for escape characters, but it didn't work. Thanks,

    modified on Wednesday, April 1, 2009 11:11 PM

    J 1 Reply Last reply
    0
    • L LiYS

      Hi all, Is there any build in string comparison or filter method that could ignore escaped character(like /r/n) & html tags(like
      )? I've tried the regular expression like "Regex.Replace(xml, "\\.", "");" for escape characters, but it didn't work. Thanks,

      modified on Wednesday, April 1, 2009 11:11 PM

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      There isn't such a thing built in the .NET framework class libraries. You could build your own like this:

      public static string GetStringWithoutEscapedSequences(string input)
      {
      var escapedSequences = new[] { "\r\n", "<br>" };
      foreach(var sequence in escapedSequences)
      {
      input = input.Replace(sequence, string.Empty);
      }
      return input;
      }

      Then compare your strings like this:

      var first = GetStringWithoutEscapedSequences(strA);
      var second = GetStringWithoutEscapedSequences(strB);

      var areEqual = string.Equals(first, second);

      Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon Judah Himango

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups