string comparision ignores escape sequence and html tags [modified]
-
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
-
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
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