ASP.NET MVC – Regex to allow less than character safely

I have a ASP.NET MVC 5 app where my business users require to enter a < (less than sign). For their specific business segment the < is a common used sign. I know about the problem of XSS-Attacks, but I’m trying to find a solution to allow just the < without opening XSS-Attacks. I DON’T want to allow HTML, so I don’t what to set [AllowHtml] or disable the validation rules. They should be turned on.

how to restrict textbox with specific format using asp.net regular expression validator

I have text which is binded to asp.net regular expression validation. I want max length of character as 13 and want to have format like xx/xxxxx-xxxx This are valid formats 33/34567-1 33/12345-12 33/12345-123 33/12345-1234 I tried this <asp:TextBox ID="txt1" runat="server" OnTextChanged="txt1_TextChanged" class="textNormal" MaxLength="13" Width="100"></asp:TextBox> (xx/xxxxx-xxxx) <br /> <asp:RegularExpressionValidator ID="regexValidator1" runat="server" ErrorMessage="Must be in format xx/xxxxx-xxxx" … Read more

Clearing unwanted hex characters with/without regex in c#

I have to clear hex characters from exception message in a better way. For now it works replacing characters manually which seems total disaster like this : var clearedStr = str.Replace(Convert.ToString((char)0x01), "") .Replace(Convert.ToString((char)0x02), "") .Replace(Convert.ToString((char)0x03), "") .Replace(Convert.ToString((char)0x04), "") .Replace(Convert.ToString((char)0x05), "") .Replace(Convert.ToString((char)0x06), "") .Replace(Convert.ToString((char)0x07), "") .Replace(Convert.ToString((char)0x08), "") .Replace(Convert.ToString((char)0x0B), "") .Replace(Convert.ToString((char)0x0C), "") .Replace(Convert.ToString((char)0x0E), "") .Replace(Convert.ToString((char)0x0F), "") .Replace(Convert.ToString((char)0x10), … Read more

Regular expression for asp:RegularExpressionValidator with format MMddyy (leap year issue)

We need help for regular expression that work with asp.net asp:RegularExpressionValidator to validate date in MMddyy format. Problem we are facing is leap year. Issue is that is it possible to verify through regular expression that it only accepts valid leap year dates like 02/29/2008 is a valid date but 02/29/2010 is not a valid date.