Created
October 30, 2015 18:05
-
-
Save jdowd7/886adfed6fda34c9aec1 to your computer and use it in GitHub Desktop.
Check for XML encoded chars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ValidationResult EscapedAmpersand(string sampleStr) | |
{ | |
Regex specChar = new Regex(@"&(?!(?:apos|quot|[A-Za-z0-1!?.,\ -]|amp);|#)", RegexOptions.IgnoreCase); | |
MatchCollection matches = specChar.Matches(sampleStr); | |
if (matches.Count > 0) | |
{ | |
return new ValidationResult("Message cannot contain special characters."); | |
} | |
return ValidationResult.Success; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment